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-
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 –
public String toString()
public int hashCode()
public boolean equals( @Nullable Object anObject )
public final Class getClass()
public final void wait() throws InterruptedException
public final void wait(long ms) throws InterruptedException
public final void notify()
public final void notifyAll()
Similar Java Tutorials
- Method to print exception information in Java
- Exception Handling by Using try-catch in Java
- Checked Exception vs Unchecked Exception
- Exception Hierarchy in Java
- Java Exception Handling Interview Questions
- final finally finalize in java
- User Defined Exception in Java
- Exception Handling Keyword in Java
- throw throws in Java
- try with multiple catch block in Java
- Threads in Java
- Thread priority in Java
- Threads communication in Java
- Daemon Thread in Java