Tuesday, April 17, 2018

Why the java.lang.System neither abstract nor instantiable

It’s to prevent you from making a subclass that can be instantiated. In Java:

* an abstract class cannot be instantiated, but its subclasses can be

* a final class cannot be subclassed

* a class cannot be both final and abstract

The System class has a private constructor to prevent you from instantiating it (this is good practice for “utility classes”), and it is final to prevent you from getting around that by creating a subclass that has a usable constructor. And because it is final, it cannot be abstract

Regards: https://www.quora.com/Why-isn-t-the-Java-lang-system-class-in-Java-an-abstract-when-it-cannot-be-instantiated/answer/Jon-Harley?share=782923fd&srid=h5t7z