I was watching a lecture on Java when I caught myself not specifying package in Java file.
They lecturer was using Java 11 on Netbeans, and I Java 1.8 on IDEA. By default Netbeans created him a package, and the main java file has package specified.
But on IDEA, I noticed that I don't need to specify package name, when creating .java
file inside src\main\java
folder. And I have a question why?
- Why is src\main\java a folder, and not a package?
- What is the difference between a folder and a package?
- In Python, they create
__init__.py
file inside of a package, in order to make Python interpreter see the package. How is it working in Java, if there is no__init__
file? How does Java understand that this is a folder, and that is a package? - Why does Java need to introduce and separate folder and package terms?