
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();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.