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.



Final Class in Java

A final class is simply a class that can’t be extended, however that a final class can still extend another non-final class, it is mainly needed for efficiency and security reasons.

As an Example:
If the equals method of a class is defined manually, this class can be considered to be defined as final to prevent being extended by a Subclass. Logically, if this equals method is called by it’s Subclass, the property of equality might not be guaranteed for the Subclass.


Reference (final in java):

Super and extends in java generic

Question about java generic:
Why is “extends T” allowed but not “implements T”?


There is no semantic difference in the generic constraint language between whether a class ‘implements’ or ‘extends’. The constraint possibilities are ‘extends’ and ‘super’ – that is, is this class to operate with assignable to that other one (extends), or is this class assignable from that one (super).


Additional Example of super and extends in java generic:

Randomized Algorithms