I tried to get method names using Reflection, I wrote below two classes:
package com.test;
public class Test {
private void method1() {
}
}
.
package com.test;
import java.lang.reflect.Method;
public class Test2 {
public static void main(String[] args) throws SecurityException, ClassNotFoundException {
Method[] m = Class.forName("com.test.Test").getMethods();
for (Method method : m) {
System.out.println(method.getName());
}
}
}
Instead getDeclaredMethods()I used getMethods(), I got the following output:
equals
hashCode
toString
getClass
notify
notifyAll
wait
wait
wait
My question is: Why is the method waitrepeated three times?
source
share