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()

This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap