Why do java source files require package declarations?
问题 I think I am failing to understand java package structure, it seemed redundant to me that java files have a package declaration within, and then are also required to be present in a directory that matches the package name. For example, if I have a MyClass.java file: package com.example; public class MyClass { public static void main(String[] args) { System.out.println("Hello, World"); } } Then I would be required to have this file located in com/example , relative to the base directory, and I