O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Discovering Method Information

Class c = someObject.getClass();
											Method[] methods = c.getMethods();
											for (int i = 0; i < methods.length; i++) {
											String methodName = methods[i].getName();
											System.out.println("Name: " + methodName);
											String returnType =
											methods[i].getReturnType().getName();
											System.out.println("Return Type: " + returnType);
											Class[] paramTypes =
											methods[i].getParameterTypes();
											System.out.print("Parameter Types:");
											for (int k = 0; k < paramTypes.length; k ++) {
											String paramTypeStr = paramTypes[k].getName();
											System.out.print(" " + paramTypeStr);
											}
											System.out.println();
											}

You can get information about a class’s public methods by calling the getMethods() method on a Class object. This method returns an array of Method objects. Using the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required