Object class in Java

Object is the base class for all other objects in Java. Any class inherits from Object and, accordingly, inherits its methods:

  1. public boolean equals(Object obj) - is used to compare objects by value;
  2. int hashCode() - returns the hash code for the object;
  3. String toString() - returns the string representation of the object;
  4. Class getClass() - returns the class of the object at runtime;
  5. protected Object clone() - creates and returns a copy of the object;
  6. void notify() - resumes the thread waiting for the monitor;
  7. void notifyAll() - resumes all threads waiting on the monitor;
  8. void wait() - stopping the thread that called the method until another thread calls the notify() or notifyAll() method for this object;
  9. void wait(long timeout) - stopping the thread that called the method for a certain time or until another thread calls the notify() or notifyAll() method for this object;
  10. void wait(long timeout, int nanos) - stopping the thread that called the method for a certain time or until another thread calls the notify() or notifyAll() method for this object;
  11. protected void finalize() - can be called by the garbage collector when the object is removed by garbage collection.

Read also:


Comments

Popular posts from this blog

Methods for reading XML in Java

XML, well-formed XML and valid XML

ArrayList and LinkedList in Java, memory usage and speed