文章目录
JDK中主要的包
导入包
无重名
package com.ssc.test2;
import com.ssc.test1.*; //降低编译速度,不会降低运行速度
public class Test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Test1 uTest1 = new Test1();
uTest1.sscMethod();
}
}
有重名记得写全名导入
// 有重名的记得加入全名
com.ssc.test1.Test1 uTest2 = new com.ssc.test1.Test1();
uTest2.sscMethod();
导入静态属性和方法
//降低编译速度,不会降低运行速度
import com.ssc.test1.*;
import static com.ssc.test1.*;
public class Test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Test1 uTest1 = new Test1();
uTest1.sscMethod();
// 有重名的记得加入全名
com.ssc.test1.Test1 uTest2 = new com.ssc.test1.Test1();
uTest2.sscMethod();
uTest2.sscMethod1();
System.out.println(uTest1.age);
}
}