Hey guys in this article, you will learn about the methods available in Object class in Java programming language.
Read More:
- Check the Complete Spring MVC Tutorials
- Check the Complete JSP Tutorials
- Check the Complete Spring Boot Tutorials [100+ Examples]
- Check the Complete Spring Boot and Thymeleaf Tutorial
- Check the Complete AWS Tutorial
- Check the Complete JavaServer Faces (JSF) Tutorial
- Check the Complete Spring Data JPA Tutorial
- Check the Complete Spring Security Tutorial
- Check the Javascript Projects for Beginners
- Check the Spring Boot JdbcTemplate Tutorials
Method of Object class
The object class is the parent class of all the classes in java by default.
Method | Description |
public final Class getClass() |
returns the Class class object of this object. The Class class can further be used to get the metadata of this class. |
public int hashCode() |
returns the hashcode number for this object. |
public boolean equals(Object obj) |
compares the given object to this object. |
protected Object clone() throws CloneNotSupportedException |
creates and returns the exact copy (clone) of this object. |
public String toString() |
returns the string representation of this object. |
public final void notify() |
wakes up single thread, waiting on this object’s monitor. |
public final void notifyAll() |
wakes up all the threads, waiting on this object’s monitor. |
public final void wait(long timeout)throws InterruptedException |
causes the current thread to wait for the specified milliseconds, until another thread notifies (invokes notify() or notifyAll() method). |
public final void wait(long timeout,int nanos)throws InterruptedException |
causes the current thread to wait for the specified milliseconds and nanoseconds, until another thread notifies (invokes notify() or notifyAll() method). |
public final void wait()throws InterruptedException |
causes the current thread to wait, until another thread notifies (invokes notify() or notifyAll() method). |
protected void finalize()throws Throwable |
is invoked by the garbage collector before object is being garbage collected. |
That’s it for this post, if you like this post, share this with your friends and colleagues or you can share this within your social media platform. Thanks, I will see you in our next post.