Packages are utilized as a part of Java so as to avert naming clashes, to control access, to make seeking/placing and utilization of classes, interfaces, identifications and annotations less demanding, in addition to several others. A Package can be described as a collection of related types (classes, interfaces, counts and annotations) giving access security and name space administration.
A few packages available in Java are::
- java.io – all the classes for output and input are available in this package
- java.lang – all the major classes are available in this package
Developers can create their own packages or package collections of classes/interfaces, and so on. It is a decent practice to collect related classes executed by you so that a software engineer can undoubtedly discover that the interfaces, classes, annotations and counts can be connected. Since the package makes another namespace, there won’t be any name clashes with names in different packages. Utilizing packages, it is less demanding to give access control and it is likewise simpler to find the related classes.
At the point when you create a package, you ought to pick a name and put a explanation with that name at the highest point of each source record that contains the classes, interfaces, lists, and annotation sorts that you need to incorporate in the package. The package declaration ought to be the first line in the source record. There can be one and only declaration in each one source record, and it applies to various sorts in the file. In the event that a declaration of interface is not utilized, then the interfaces, class, annotation and specifications will be put in a package, which will be unnamed.
For any query or issue, feel free to discuss on http://discuss.eduguru.in