Java中静态导包 / import static的简单例子
例子1
import static java.lang.System.*;
省略程序中所有的System,如:
out.println("Hello World"); //正确
exit(0); //正确
例子2
import static java.lang.System.out;
只省略使用out时的System,如:
out.println("Hello World"); //正确
exit(0); //错误,无法通过编译
优点.
原创
2021-02-01 17:15:40 ·
176 阅读 ·
0 评论