In the code of a legacy application I just came across a class file that contained inner classes, but those inner classes where not defined within the class body but after the closing bracket of the class definition.
It looked silike this:
MyClass.java
public class MyClass { // class body } class DataStructure1 { String field1; Integer field2; } class DataStructure2 { Date field3; String field4; } Obviously the compiler does not complain, but I was quite irritated as I've never seen something like this before.
- Are this valid inner classes?
- Is there any difference to classes defined within the body (except from indentation)?