package in java is used to group class and interfaces. This helps developer to avoid conflict when there are huge numbers of classes. If we use this package the classes we can create a class/interface with same name in different packages. By using packages we can import the piece of again in another class. There many built in packages in java like > 1.java.util > 2.java.lang > 3.java.io We can define our own user defined packages.
Packages provide access protection.
package statement must be first line of source code. There can only be one package in one source file.
With help of packages conflict between different modules can be avoided.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0