Static nested class in Java

Java has “static nested classes“. A static nested class is just one which doesn’t implicitly have a reference to an instance of the outer class. This saves the 8-byte inner class object overhead.

Static nested classes can have instance methods and static methods. There’s no such thing as a top-level static class in Java. Class can be labeled as final and static to simulate this behavior, and the constructor should be also made “private” to prevent instantiation.



About yingding wang
i am looking forward to innovation in IT and Robotics

Comments are closed.

%d bloggers like this: