Object Class
Package: java.lang
Object is the mother of all classes. Every class ultimately inherits the Object class. This class provides a set of methods available to every Java object.
Methods
|
Method |
What It Does |
|
|
Returns a copy of this object. |
|
|
Indicates whether this object is equal to the |
|
|
Is called by the garbage collector when the object is destroyed. |
|
|
Returns a |
|
|
Returns this object’s hash code (a calculated value that uniquely identifies the object). |
|
|
Is used with threaded applications to wake up a thread that’s waiting on this object. |
|
|
Is used with threaded applications to wake up all threads that are waiting on this object. |
|
|
Returns a |
|
|
Causes this object’s thread to wait until another thread calls |
|
|
Is a variation of the basic |
|
|
Is yet another variation of the |
Using Object as a type
If you don’t know or care about the type of an object referenced by a variable, you can specify its type as Object. The following example is perfectly legal:
Object emp = new Employee();
You can’t do anything useful with the emp variable, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access