Effective Kotlin: Item 25 — Limit source files to a single top-level class

Matthew Dolan
Sep 3, 2018 · 2 min read

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”.

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade