Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nagendran
NoSuchMethodException
1 Answer(s)      2 years and 8 months ago
Posted in : Java Interview Questions


whis is the NoSuchMethodException in java? or define NoSuchMethodException with exp?


Advertisement
View Answers

March 28, 2012 at 1:46 PM


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();
  }

}


Related Tutorials/Questions & Answers:
NoSuchMethodException
NoSuchMethodException  whis is the NoSuchMethodException in java? or define NoSuchMethodException with exp?   This Exception occurs when... (NoSuchMethodException e) { e.printStackTrace(); } } catch
NoSuchMethodException even if method defined - Java Beginners
NoSuchMethodException even if method defined  Hi I am loading a class (Student) dynamically from a jar (samplejar.jar) file using URLClassLoader. Next thing when I want to access method or constructor of the previously loaded
Advertisements
No Argument Constructor Example
newInstance() method throws a NoSuchMethodException if the class does not have any
Exception handling in java
IIIegalAccessException. NoSuchMethodException. Checked Exception Reason.... NoSuchMethodException NOtSuchMethodException is displayed when we have called method
Exception Classes
- NoSuchMethodException Nonexistent method YES
Making Exceptions Unchecked - java tutorial,java tutorials
InstantiationException InterruptedException NoSuchFieldException NoSuchMethodException
Advertisements
 

 

 

DMCA.com