What is the purpose of using static to import package?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
What does the “static” modifier after “import” mean?
1 | import static java.nio.file.StandardOpenOption.APPEND; |
静态在其中的作用是什么?为什么是强制性的?
this should help Oracle文档:http:////docs.oracle.com javaSE 1.5.0 /文档/导游/语言/ static-import.htmlP></
copied from here。P></
Static import is a feature introduced in the Java programming language
that allows members (fields and methods) defined in a class as public
static to be used in Java code without specifying the class in which
the field is defined. This feature was introduced into the language in
version 5.0.
因为在你的代码,你可以使用:P></
1 | APPEND |
如果你不imported this as You had to给全静态路径:P></
1 | java.nio.file.StandardOpenOption.APPEND; |