![]() |
VOOZH | about |
The java.lang.reflect.Method.equals(Object obj) method of Method class compares this Method Object against the specified object as parameter to equal(object obj) method. This method returns true if the Method object is the same as the passed object. Two Methods are the same if they were declared by the same class and have the same name and formal parameter types and return type.
public boolean equals(Object obj)
Parameter
Return Value
The below program illustrates equals(Object obj) method of Method class:
Examples 1: When both objects are the same.
First Method object from array create by getMethods(): public java.lang.String GFGClass.add(java.lang.String) Method object created by getMethod(): public java.lang.String GFGClass.add(java.lang.Strin...
Example 2: When both objects are not the same.
Methods are : public java.lang.String GFGClass.getField1() public void GFGClass.setField1(java.lang.String) Methods are not equal