How do I list the public methods of a class?
Author: Deron Eriksson
Description: This Java tutorial describes how to use the Class object's getMethods() method.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.4


Page: < 1 2

(Continued from page 1)

If we execute ClassMethodTest, we see the following result in the console:

public method: public boolean test.Testing.isBoolean1()
public method: public void test.Testing.setBoolean1(boolean)
public method: public java.lang.String test.Testing.getString1()
public method: public void test.Testing.setString1(java.lang.String)
public method: public native int java.lang.Object.hashCode()
public method: public final native java.lang.Class java.lang.Object.getClass()
public method: public final void java.lang.Object.wait() throws java.lang.InterruptedException
public method: public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public method: public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public method: public boolean java.lang.Object.equals(java.lang.Object)
public method: public final native void java.lang.Object.notify()
public method: public final native void java.lang.Object.notifyAll()
public method: public java.lang.String java.lang.Object.toString()

As you can see, all the public methods of the Testing class are displayed, including the methods that the class inherited.

Page: < 1 2