Reputation: 331
I have a silly question, I have two projects A and B. A is dependent on B. Both A and B have the same package named P. Why classes under project A and Project B in package P can use each other without import.
Upvotes: 1
Views: 1774
Reputation: 4657
Because the Java compiler doesn't care how you organize your code. There is no concept of "Project" in Java, per se.
If the class is available on the classpath at compile-time and it is in the same package as the importing class, no import statement is necessary.
Upvotes: 3
Reputation: 2045
The classloader doesn't care if classes are from different jar files or a single jar file, when it checks for other classes. Therefore no import is needed, if the classes are in the same package.
Upvotes: 0