Search⌘ K

Object Superclass

Explore the Java Object superclass and discover how all classes inherit from it by default. Learn to override crucial methods like toString() and equals() to customize how objects are represented as strings and compared, enhancing your coding skills in Java.

What is the Object class?

The Object class is the superclass of all the other classes in Java. It’s part of the java.lang package.

If a parent class isn’t specified using the extends keyword, the class will inherit from the Object class. For example:

public class A
{
   // class defintion
}

Here, class A inherits from the Object class by default.

✏️ Note: Here’s the complete official documentation of the Object class.

Methods from the Object class

The following two main methods of Object class are used:

  • The
...