getClass(): This method is available in the java.lang.Object class of Java.
Syntax:
Class<? extends Object> java.lang.Object.getClass()
This method returns the runtime class of this Object. The returned Class object is the object that is locked by static synchronized methods of the represented class.
Parameters: NA
Returns: The Class object that represents the runtime class of this object.
Exceptions: NA
Approach
Java
public class ObjectgetClass {public static void main(String[] args) {Object object = new Object();System.out.println(object.getClass());}}
Output:
class java.lang.Object
Some other methods of Object Class.
equals(): This method indicates whether some other object is "equal to" this one.
hashCode(): This method returns a hash code value for the object.
toString(): This method returns a string representation of the object.
No comments:
Post a Comment