I have been learning java and using eclipse. So my question is what is the purpose of a package, and why can't there just be projects and classes?
Asked
Active
Viewed 119 times
0
-
https://docs.oracle.com/javase/tutorial/java/package/ – OldProgrammer Jun 24 '15 at 01:51
2 Answers
2
Packages are a way to group/organize/separate your classes depending of the a common functionality. So, say you have a set of classes that deal with storing multiple objects (such as the collections package) or you could have a package of classes that deal with File manipulation: such as the java.io.* package.
It's just a way of organizing.

Manuel Manrique
- 21
- 3
1
In addition to what @Manuel Manrique has said, one thing that I could think of is, packages help resolve class/interface naming conflicts
For ex: I use some-apache.jar and some-google-api.jar, assuming both have same class named Test
, packages help resolve the conflict.
In general package naming convention is something like org.apache.Test
or com.google.Test

JavaHopper
- 5,567
- 1
- 19
- 27