3 ms·
That comment might be for programmers coming from languages where filenames do matter to the compiler, or languages like Java where the convention is so univers
by dkarl 6y ago
That comment might be for programmers coming from languages where filenames do matter to the compiler, or languages like Java where the convention is so universally followed that many programmers don't know you can break it. Someone programming for the first time already "knows" that filenames don't matter, so it's probably not for them.
- Kwpolska 6y agoIn Java, the “each public class is in its own file named after the class” rule is enforced by the compiler and there’s no switch to disable this behavior.
- dkarl 6y agoI guess that shows how uniformly the convention is followed that I wasn't aware of that! I remember finding a class in a PR that had been renamed without renaming the file, and we were surprised it compiled. It must not have been a public class. $ echo "class Bar { }" > Foo.java $ javac Foo.java $ ls Bar.class Foo.java $
- pjmlp 6y agoThat is not a public class. If you don't specify any access modifier, it is the same as internal in .NET.
- pjmlp 6y agoTrue, but many don't realize that package private and "friend" classes can share the same source file.