As we go down our years of learning and coding in Java, we tend to forget some basics. Did you know that you can define more than one class in the same java file? The only condition being that among the classes defined in a .java file, only one can be public. The other classes have to be of default (package) scope. The following is perfectly legal in a file called Class1.java where Class1 is the public class:
public class Class1 {
}
class Class2 {
}
Where do we use this?
Again, just like the Local Classes, need to figure this out. Please share your thoughts by commenting. Thanks. Will probably do a dedicated post on thoughts of where to use which kind of class.