ERROR - java.lang.NoSuchMethodException: Class.methodName (Parameter)

Error

 java.lang.NoSuchMethodException: Class.methodName (Parameter)

at java.lang.Class.getMethod(Class.java:1778)

Error Type

Run Time

Sample Code

Method method = BuggyBreadClass.class.getMethod( "myMethod", String.class );

Cause

Method being referenced doesn't exist.

Resolution

Make sure that the method being referenced should exist in the class. It should have the same name, should have the specified perimeter(s) and should have the adequate access.

In the above example - Make sure that myMethod exists in BuggyBreadClass and should take only one String argument and shouldn't be declared private.