静态导入
import导包
(1)import 包.类名;
(2)import 包.;
(3)import static 包.类名.静态成员;
(4)import static 包.类名.;
具体的情况看代码的演示:
//import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
//这个样子导包的话就可以把ElementType省略了,代码就不会特别的长
import static java.lang.annotation.ElementType.*;
import static java.lang.Math.*;
public class TestStaticImport {
public static void main(String[] args) {
// System.out.println(Math.PI);
// System.out.println(Math.sqrt(6));
System.out.println(PI);
System.out.println(sqrt(6));
}
}
//@Target({ElementType.METHOD,ElementType.FIELD,ElementType.TYPE})
@Target({METHOD,FIELD,TYPE})
@interface C{
}