Java Class getMethods() Method

The getMethods() method of java Class class returns an array containing the method objects which represent all the public methods of the class or interface represented by a Class object, including those declared by the class or interface and inherited from superclasses and super interfaces.

Syntax

Parameter

NA

Returns

The array of Method objects

Throws

Does not throw an exception

Example 1

Test it Now

Output:

Methods =
public void java.awt.Label.addNotify()
public javax.accessibility.AccessibleContext java.awt.Label.getAccessibleContext()
public int java.awt.Label.getAlignment()
public java.lang.String java.awt.Label.getText()
public synchronized void java.awt.Label.setAlignment(int)
public void java.awt.Label.setText(java.lang.String)
public void java.awt.Component.add(java.awt.PopupMenu)
public void java.awt.Component.remove(java.awt.MenuComponent)
public java.lang.String java.awt.Component.toString()
public void java.awt.Component.update(java.awt.Graphics)
public java.lang.String java.awt.Component.getName()
public boolean java.awt.Component.contains(int,int)
public boolean java.awt.Component.contains(java.awt.Point)
public java.awt.Dimension java.awt.Component.size()
public java.awt.Point java.awt.Component.getLocation(java.awt.Point)
public java.awt.Point java.awt.Component.getLocation()
public java.awt.Container java.awt.Component.getParent()

Example 2

Test it Now

Output:

public static void ClassgetMethodsExample2.main(java.lang.String[])
public int ClassgetMethodsExample2.Calc(int)
public void ClassgetMethodsExample2.Work()
public static void ClassgetMethodsExample2.StaticMethod(java.lang.String)
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public boolean java.lang.Object.equals(java.lang.Object)
public java.lang.String java.lang.Object.toString()
public native int java.lang.Object.hashCode()
public final native java.lang.Class java.lang.Object.getClass()

Next TopicJava Class




Latest Courses