* You can call the private method from outside the class by using Java Reflection API.
* Java Reflection is a process of examining or modifying the run time behavior of a class at run time.
* By the help of java.lang.Class class and java.lang.reflect.Method class, we can call a private method from any other class.
Method of Class class :
public Method getDeclaredMethod(String name,Class[] parameterTypes)
throws NoSuchMethodException,SecurityException
Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object.
Methods of Method class
public void setAccessible(boolean status) throws SecurityException
* Sets the accessibility of the method true or false.
public Object invoke(Object method, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
*Used to invoke the method.
DOWNLOAD EXAMPLE CODE
* Java Reflection is a process of examining or modifying the run time behavior of a class at run time.
* By the help of java.lang.Class class and java.lang.reflect.Method class, we can call a private method from any other class.
Method of Class class :
public Method getDeclaredMethod(String name,Class[] parameterTypes)
throws NoSuchMethodException,SecurityException
Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object.
Methods of Method class
public void setAccessible(boolean status) throws SecurityException
* Sets the accessibility of the method true or false.
public Object invoke(Object method, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
*Used to invoke the method.
1 comment:
Casino of the World - South Africa - JTM Hub
Casino of 파주 출장마사지 the World. South Africa. South Africa. 1xbet app Casino of 화성 출장안마 the World. South Africa. Casino of the World. South Africa. Casino of the World. South Africa. South Africa. Casino of 경주 출장샵 the World. 김해 출장안마 South Africa. South Africa.
Post a Comment