3 ms·
In Java, it is perfectly acceptable to have either a file containing the primary public class and any number of private utility and implementation classes, or j
by legerdemain 6y ago
In Java, it is perfectly acceptable to have either a file containing the primary public class and any number of private utility and implementation classes, or just have a non-instantiatable enclosing class that works as a module and a bunch of interfaces, classes, and enums within it. Consumers then can then refer to them either by their Class.SubClass name or the shorter SubClass name.
- js8 6y agoOK, thanks! I didn't realize it is possible, I haven't seen code that uses this technique.
- watwut 6y agoTypically nested classes in Java make it harder to follow what each class does, where it ends and starts. The files then tend to become too big and at worst end up cross referencing each others privates too much. At least, that is my experience with code that uses nested classes all the time and - I am slowly refactoring it to split classes into separate files.