What are packages in Java?As the size of a project grows larger, the manageability of the files in it becomes tedious. Smaller projects can have the related files stored at a single location.
Due to this problem with larger codes, packages can be effectively used to deal with it.
The files with certain functionality can be kept separately from files with different functionality in a directory or a package.
Eg.: Files in java.io package contain I/O related functionality whereas files in java.net package contain network related functionality.
Package is a collection of classes that avoids name space collision.
Multiple classes with the same name cannot be created in a single package.
A class hierarchy can be created and kept in a package.
Packages can also be considered as a container for classes.
|