Java Object Class
The Java Object class is the parent class of all classes, that is, all classes in Java inherit 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 it does not explicitly inherit a parent class, it will automatically inherit Object and become a subclass of Object.
The Object class can be inherited either explicitly or implicitly. The following two ways are the same:
Explicit inheritance:
public class Example extends Object{
}
Implicit inheritance:
public class Example {
}
Class constructors
| No. | Constructor & Description |
|---|---|
| 1 |
Object() Constructs a new object. |
Class methods
| No. | Method & Description |
|---|---|
| 1 | protected Object clone()
Creates and returns a copy of an object |
| 2 | boolean equals(Object obj)
Compares whether two objects are equal |
| 3 | protected void finalize()
When the GC (Garbage Collector) determines that there are no more references to the object, this method is called by the object's garbage collector. |
| 4 | Class<?> getClass()
Gets the runtime class of the object |
| 5 | int hashCode()
Gets the hash value of the object |
| 6 | void notify()
Wakes up a single thread waiting on that object |
| 7 | void notifyAll()
Wakes up all threads waiting on that object |
| 8 | String toString()
Returns the string representation of the object |
| 9 | void wait()
Causes the current thread to enter the waiting state until another thread calls the notify() method or the notifyAll() method of this object. |
| 10 | void wait(long timeout)
Causes the current thread to enter the waiting (blocked) state until another thread calls the notify() method or notifyAll() method of this object, or the timeout period set by the parameter is exceeded. |
| 11 | void wait(long timeout, int nanos)
Similar to the wait(long timeout) method, it has an additional nanos parameter, which represents the extra time (in nanoseconds, range 0-999999). Therefore, the timeout time also needs to add nanos nanoseconds. |