Effective Kotlin: Item 25 — Limit source files to a single top-level class
Highlighted in item 25 of the fantastic Effective Java by Joshua Bloch is the inner workings of the javac compiler and how it silently compiles source files not mentioned on the command line but referenced by those that are. In the book’s example, the
main class references a
Utensil class and so calling
javac Main.java looks for a Utensil.java file automatically which on executing outputs “pancake”. If instead, you use the command
javac Dessert.java Main.java it will print “potpie”.