Deep Dive: Java Object Class from java.lang Package


Introduction to the Object Class

The Object class from java.lang package is the root class of all classes in Java Programming Langauge. All classes have the Object class as its Superclass (Parent class).

✏️ Object class is available since Java version 1.0


How to view the Object Class Code?

You can find the Object.class file in the core API rt.jar (Java Runtime Environment), If you use IDE like IntelliJ or Visual Studio Code, you can make use of the built-in decompiler.

Using IntelliJ:

  • Right Click on the Object keyword in a file and select Go To -> Implementation (s)
How to view Object class implementation using IntelliJ
Java Object Class Code

You can also make use of decompilers or view the code online http://www.docjar.com/html/api/java/lang/Object.java.html.


List of Methods in Object.java class

12 Methods of the Java Object Class

There are 12 methods available in the Object class. The methods from the Object class are available for all classes that we create. Out of these 12 methods, 7 methods are of type native - they are defined and executed using code written in another programming language native to the Operating System (mostly C Langauge)

  1. private static native void registerNatives();
  2. public final native Class<?> getClass();
  3. public native int hashCode();
  4. protected native Object clone();
  5. public final native void notify();
  6. public final native void notifyAll();
  7. public final native void wait(long timeout);
  8. public boolean equals(Object obj)
  9. public String toString()
  10. public final void wait(long timeout, int nanos)
  11. public final void wait()
  12. protected void finalize()
-


Have Questions? Post them here!

Topics Coverage:


🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram