static
and abstract
can be used together for nested classes, eg
class A {
static abstract class B {
abstract void someMethod();
}
}
B
is a static
nested class that requires concrete subclasses to implement someMethod()
.
but cannot be used together for methods, eg
static abstract void someMethod(); // compile error
Of course abstract
and final
can't be used together - such a combination would be nonsensical.
Uses of static abstract class
A suitable use of a static abstract class
would be for node-like objects that only your class uses, for example a class the represent an entry in a map (eg java.util.Map.Entry
which is an interface
, but could have been a static abstract class), or a class for a node of a LinkedList
, but one where the implementation is left to implementatioons of the enclosing class that themselves also use and provide implementations of the nested class by extending it too.