Java Method.hashCode()
Syntax
Method.hashCode() has the following syntax.
public int hashCode()
Example
In the following code shows how to use Method.hashCode() method.
import java.lang.reflect.Method;
// ww w . j a v a2s . c om
public class Main {
public static void main(String[] args) {
String name = "java.util.Date";
try {
Class cl = Class.forName(name);
printMethods(cl);
} catch (ClassNotFoundException e) {
System.out.println("Class not found.");
}
}
public static void printMethods(Class cl) {
Method[] methods = cl.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method m = methods[i];
System.out.println(m.hashCode());
}
}
}
The code above generates the following result.