Advantages of using packages in Java
Following are the advantages of using packages in Java −
- Programmers can define their own packages to bundle a group of classes/interfaces, etc.
- It is a good practice to group related classes implemented by you so that a programmer can easily determine that the classes, interfaces, enumerations, and annotations are related.
- Since the package creates a new namespace there won't be any name conflicts with names in other packages.
- Using packages, it is easier to provide access control
- It is also easier to locate the related classes.
Suppose you have developed a very large application that includes many modules. As the number of modules grows, it becomes difficult to keep track of them all if they are dumped into one location. This is particularly so if they have similar names or functionality. You might wish for a means of grouping and organizing them.
Published on 05-Feb-2018 09:50:49