1 /* 2 包的机制:(1) 3 */ 4 package lee; 5 public class PackageTest 6 { 7 public void Test(int num) 8 { 9 System.out.println("num="+num); 10 } 11 } 12 13 //包的使用:(2) 14 package lee.sub; 15 public class SubPackageTest 16 { 17 public void sub(int x) 18 { 19 System.out.println("x="+x); 20 } 21 } 22 23 //包机制;(3) 24 package lee; 25 import lee.sub.SubPackageTest; 26 public class PackageTest1 27 { 28 public static void main(String[] args) 29 { 30 PackageTest pc = new PackageTest(); 31 pc.Test(4); 32 33 /*lee.sub.*/SubPackageTest sb = new /*lee.sub.*/SubPackageTest(); 34 sb.sub(7); 35 36 System.out.println("Hello PackageTest1..."); 37 } 38 }
时间: 2024-10-05 22:06:30