Package and references

Package: Similar to the way a computer's file management, mainly to solve the same name.

  Package to help manage large-scale software systems: semantic class organization similar to the package; problem-solving class naming conflicts.

  And a sub-package may comprise a package classes.

  Keyword --package

  package statement as the first statement Java source files of the package specified in the file where the class definition. If the default statement is designated as the unnamed package.

  Format: Package Penalty for top-level package name sub-package name;.

  Packet corresponding to the file system directory, Package statements, used to specify the level package (directory). "";

  Package usually lowercase words, the class name is usually the first letter capitalized.

  Keyword --import

  Using Java classes defined in different packages, it is necessary to introduce import statement specified or all classes required level package (. *). The import statement tells the compiler where to find classes.

  Format: Import package names [Name subpacket.] <Class name | *>.

  note:

  If the package is introduced: Java.lang, the compiler default class available in this package, no explicit statement.

  The import statement appears after the package statement, before defining the class.

  A source file may contain a plurality of import statement.

  Can import lee *;. Statement indicating import all the classes in the lee package. While class lee package under sub sub-packets are not introduced.

  import statement is not required, other classes may stick with the full name of the class.

  JDK1.5 added import static statement.

Guess you like

Origin www.cnblogs.com/fangfangfanga/p/12037067.html