O'Reilly logo
  • Oleksandr Ivanov thinks this is interesting:

The name of the file must match the name of the class.

From

Cover of OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808

Note

small remark: "must match the name of the PUBLIC class".
E.g.
if you have file with name Foo.java it is possible to compile it with content inside:
class Bar {} but NOT public class Bar{}