Java Object superclass

java

Solution

`Object` is an exception to the first rule, and has no superclass. From JLS3 8.1.4:

The extends clause must not appear in the definition of the class Object, because it is the primordial class and has no direct superclass.

You can also try it out with reflection:

Object.class.getSuperclass(); // returns null

Problem

I have a weird Java question: As we know: - All Java classes extend `java.lang.Object` - All Java classes cannot extend itself Then, `java.lang.Object` must extend `java.lang.Object`, which is itself, therefore, it should be impossible. How is Object implemented in Java?

Original source