Java Object class can be thought of as the father of all other classes. This is because every class defined in Java extends directly or indirectly from the Object class. This also means that the methods of the Object class are available to all other classes in Java. Here’s how the Object class is defined in the java.lang package.

See the following figure.

Java Object Class Tutorial

/*
Note: Following is the in-built Object class defined in java.lang
package. This class is shown here just for reference.

This piece of code will not compile by itself.
*/

/*
The Object class can be seen in the terminal by using the following
command.
~$ javap java.lang.Object

*/

/*
Compiled from "Object.java"
*/

public class java.lang.Object {

  public java.lang.Object();
  public final native java.lang.Class<?> getClass();
  public native int hashCode();
  public boolean equals(java.lang.Object);
  protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
  public java.lang.String toString();
  public final native void notify();
  public final native void notifyAll();
  public final native void wait(long) throws java.lang.InterruptedException;
  public final void wait(long, int) throws java.lang.InterruptedException;
  public final void wait() throws java.lang.InterruptedException;
  protected void finalize() throws java.lang.Throwable;
  static {};

}

The above piece of code is not meant for compilation.

#java #java.lang.object class #java object

Java Object Class Example | Java.lang.Object Class
2.85 GEEK