Class NoSuchMethodError in Java

Class NoSuchMethodError in Java

NoSuchMethodError is thrown from an application if the application tries to call a static or instance method of another class and that class no longer has a method defined. So this error signals that the specified method could not be found.

It is a child class of IncompatibleClassChangeError which is a subclass of LinkageError.

A NoSuchMethodError is thrown in response to an attempt to reference a method that is not defined in the current definition of a class. Usually, this error is caught by the compiler; it can occur at run-time if the definition of a class is changed after the class that references it was last compiled.

The structure of the NoSuchMethodError class is given below:

public class java.lang.NoSuchMethodError extends java.lang.IncompatibleClassChangeError{
public NoSuchMethodError();
//constructs an empty NoSuchMethodError object that is an object with no message specified.
public NoSuchMethodError(String message);
//constructs an NoSuchMethodError object with the message specified.

The class NoSuchMethodError also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
wait(long, int)getLocalizedMessage()

Share and Enjoy !

READ  CharArrayReader Class in Java

Leave a Reply

Your email address will not be published. Required fields are marked *