import java.lang.reflect.Method; class ReflectDemo { private void method1() { System.out.println("Method-1 in Private"); } private void method2(String name) { System.out.println("Method-2 in Private "+name); } } public class PrivateReflectionDemo { public static void main(String[] args) throws Exception { ReflectDemo o =new ReflectDemo(); Class c=o.getClass(); Method m1=c.getDeclaredMethod("method1",null); m1.setAccessible(true); m1.invoke(o,null);//Object,parameter Method m2=c.getDeclaredMethod("method2",String.class); m2.setAccessible(true); m2.invoke(o,"Tutor Joes");//Object,parameter } }
Method-1 in Private Method-2 in Private Tutor JoesTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions