Getting a list of the public methods of a particular class through reflection

import java.lang.reflect.*;
public class Main {
   public static void main(String args[]) throws Exception {
      Class c = Class.forName("MyClass");   // or Class c = MyClass.getClass();
      Method []methods = c.getMethods();
      for (int i=0; i<methods.length; i++) {
class MyClass
   public MyClass() { }
   protected MyClass(float f) { }
   public String method1(int a) { return ""; }
   public float method2() { return (float) 1.2; }
   protected void method3() { }
   private double method4() { return 1.2; }


public boolean java.lang.Object.equals(java.lang.Object)
public final native java.lang.Class java.lang.Object.getClass()
public int java.lang.Object.hashCode()
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()
public java.lang.String java.lang.Object.toString()
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public java.lang.String MyClass.method1(int)
public float MyClass.method2()