class Foo is public, should be declared in a file named Foo.java

When working with Java you might encounter this error. The reason for this is that you have tried to declare a public class in a file with a different name. Each java file can only contain one public java class, which is named the same as the java file itself. If you need another class inside your other class you should looking into private inner classes.