I am learning Java Reflection, and wass playing around with the java.lang.Reflection
class. Here is the code I wrote in a class called Driver
Method[] method = Dummy.class.getMethods();
System.out.println("MEthods");
for (int i = 0; i < method.length; i++) {
System.out.println("Name: " + method[i].getName());
System.out.println("Declaring Class: " + method[i].getDeclaringClass());
System.out.println("ToGenericString: " + method[i].toGenericString());
System.out.println("Modifiers: " + method[i].getModifiers());
System.out.println();
}
Here is the Dummy class
public class Dummy {
public int b(){return 0;}
}
I would get output like the following
Name: b
Declaring Class: class Dummy
ToGenericString: public int Dummy.b()
Modifiers: 1
Name: hashCode
Declaring Class: class java.lang.Object
ToGenericString: public native int java.lang.Object.hashCode()
Modifiers: 257
Name: notifyAll
Declaring Class: class java.lang.Object
ToGenericString: public final native void java.lang.Object.notifyAll()
Modifiers: 273
//etc
My question is:
Why do the Object inherited methods such as wait()
, notify()
hashcode()
etc have over 270+ modifiers whereas my ethod b()
only has 1, interestingly enough toString()
also has 1