package reflect;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Method1 {
public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// TODO Auto-generated method stub
Class cla=Student1.class;
Student1 st = new Student1();
Method met1=cla.getMethod("setName", String.class);
met1.invoke(st, "gun");
Method met=cla.getMethod("getName", null);
Object o=met.invoke(st, null);
System.out.println(o);
}
}
gun