What is the java package

First, what is the package

Package allows the combination of the class into smaller units (similar to the folder), making it easier to find and use the corresponding class file

Pack helps avoid naming conflicts. When using a lot of class, the class name and the method is difficult to decide. Sometimes necessary to use the same name for other classes. Package basically hides the class and avoids conflicts of name

Package allows protection classes, methods, and data in a wider range, the package may be defined in the class, and the code can not be accessed outside the package of the class

Second, the declaration package and use package

We can define a package in the new class at the same time. In Eclipse as follows:

 

Guess you like

Origin www.cnblogs.com/weibanggang/p/11184636.html