What is the use of package in java?

Packages in Java are the way to organize files when a project has many modules. One important benefit of such an organization of files in different modules is that it helps resolving naming conflicts i.e., different packages may have classes with the same name. Obviously this is not possible if we don’t have the concept of packages. In that we need to find different names for all the classes, which may not be desirable in every case. Plus, packages improve making the application more modular.
We write like
Package foo.com
It should be the first statement of the program.

No comments:

Post a Comment