Easy Tutorial
❮ Java Loop Dir Modification ❯

Java Object Class

The Java Object class is the parent class of all classes, meaning that all Java classes inherit from Object. Subclasses can use all methods of Object.

The Object class is located in the java.lang package and is automatically imported at compile time. When we create a class, if we do not explicitly inherit from a parent class, it automatically inherits from Object, becoming a subclass of Object.

The Object class can be inherited explicitly or implicitly; both methods are equivalent:

Explicit inheritance:

public class tutorialpro extends Object {

}

Implicit inheritance:

public class tutorialpro {

}

Class Constructors

Number Constructor & Description
1 Object() Constructs a new object.

Class Methods

Number Method & Description
1 protected Object clone() Creates and returns a copy of the object.
2 boolean equals(Object obj) Compares two objects for equality.
3 protected void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
4 Class<?> getClass() Gets the runtime class of the object.
5 int hashCode() Gets the hash code value for the object.
6 void notify() Wakes up a single thread that is waiting on this object's monitor.
7 void notifyAll() Wakes up all threads that are waiting on this object's monitor.
8 String toString() Returns a string representation of the object.
9 void wait() Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
10 void wait(long timeout) Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.
11 void wait(long timeout, int nanos) Similar to the wait(long timeout) method but includes an additional nanos parameter, which specifies additional time (in nanoseconds, range 0-999999). The timeout period is thus extended by nanos nanoseconds.
❮ Java Loop Dir Modification ❯