So imagine this folder structure.
main\
\pack1
a\A.java
b\B.java
A.java is not in the same folder as B.java. But both have the same package statement as following:
package main.pack1;
With that package statement, they have no compiler error, if i try to access protected fields from each other. If I have the package statement as following:
package main.pack1.a;
package main.pack1.b;
for the two Files respectivly, I cannot access the protected fields of each other, as expected.
The question is, is it good practice to group classes from different folders into one package?
I want to structure the .java files in a folder structure, for better organisation (so that i dont have like 20 files in one folder), but they should be in the same package, for usage of protected fields.
I hope its clear, what im asking.