java.lang Package

The java.lang package is a fundamental and essential part of the Java Standard Library. It serves as the foundation of the Java programming language, providing core classes and utilities that are automatically imported into every Java program.

We are not required to import Java.lang package explicitly because all classes and interfaces are present in Java. lang package by default is available to every Java program.

some of the core classes found in java.lang package include-

  • Object
  • String
  • Math
  • System
  • Class
  • ThreadException


The most commonly required method for every Java class(either predefined or customized class) is defined in a separate class which is known as an Object class (java.lang.object).Every class in Java is child class of Object either directly or indirectly, due to this Object class methods is available for every Java class. Hence Object class is considered as root of all Java class.


  • If Java class does not extend any other class then Java class is the child class of Object.
  • If Java class extend any other class then Java class is indirect child class of Object.

Either directly or indirectly multiple inheritance concerning classes is not possible in Java.

Object Class Methods

Some key methods of Object Class is given bellow –

  1. public String toString()
  2. public int hashCode()
  3. public boolean equals( @Nullable Object anObject )
  4. public final Class getClass()
  5. public final void wait() throws InterruptedException
  6. public final void wait(long ms) throws InterruptedException
  7. public final void notify()
  8. public final void notifyAll()

Similar Java Tutorials

5 thoughts on “java.lang Package”

Leave a Comment