包(命名空间)
package mars; class Test{ public static void main(String args []){ System.out.println("Hello package"); } }
编译
执行(包名.类名)
java中的访问权限
- public:公共权限
- private:私有权限
- default:包级别访问权限
- protected:受保护权限
- public>protected>default>private
package org.marsdroid; public class Person{ public String name; public int age; public void introduce(){ System.out.println("name"): } }
1.
package com.marsdroid class Test{ public static void main(String s args []){ org.marsdroid.Person p=null; } }
2.
package com.marsdroid import org.marsdroid.Person class Test{ public static void main(String s args []){ Person p=null; } }