Drop Down

Sunday, January 12, 2020

Get All Methods of Objects Class

package warmUP;

import java.lang.reflect.Method;

public class Show_Methods {

public static void main(String[] args) throws ClassNotFoundException
{
int count = 0;
Class c = Class.forName("java.lang.Object");
Method[] m = c.getDeclaredMethods();
for(Method m1 : m)
{
count++;
System.out.println(m1.getName());
}
System.out.println("Total No. of Methods: "+count);
}

}
----------------------------------------------------------------
OutPut:
---------
finalize
wait
wait
wait
equals
toString
hashCode
getClass
clone
notify
notifyAll
registerNatives
Total No. of Methods: 12


No comments:

Post a Comment

Java 8 Notes Pics