whis is the NoSuchMethodException in java? or define NoSuchMethodException with exp?
This Exception occurs when the method you call does not exist in class.
Example
import java.lang.reflect.Method;
public class JavaReflectionExample2
{
public JavaReflectionExample2()
{
Class c;
try
{
c = Class.forName("java.lang.String");
try
{
Class[] paramTypes = new Class[5];
Method m = c.getDeclaredMethod("fooMethod", paramTypes);
}
catch (SecurityException e)
{
e.printStackTrace();
}
catch (NoSuchMethodException e)
{
e.printStackTrace();
}
}
catch (ClassNotFoundException e)
{
// deal with the exception here ...
e.printStackTrace();
}
}
public static void main(String[] args)
{
new JavaReflectionExample2();
}
}