Java Programming - Package
Pack01.java
class Pack01 { public static void main(String[] args) { Pack02.Obj02 obj2 = new Pack02.Obj02(); Pack02.Pack03.Obj03 obj3 = new Pack02.Pack03.Obj03(); System.out.println("Pack01"); System.out.println(obj2.GetObjName()); obj3.GetObjName(); } }
Obj02.java
package Pack02; public class Obj02 { public static void main(String[] args) { // do nothing; } public string GetObjName() { return "Obj02"; } }
Obj03.java
package Pack02.Pack03; public class Obj03 { public static void main(String[] args) { // do nothing } public void GetObjname() { System.out.println("Obj03"); } }
javac Pack01.java
compile
or javac Pack02\Obj02.java
compile
or javac Pack02\Pack03\Obj03.java
compile
java Pack01
Pack01 Obj02 Obj03