• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NoSuchMethodException

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class first{
public static void main(String[] args) throws NoSuchMethodException{
try{
first p=new first();
p.showData();
}

catch(NoSuchMethodException e){
System.out.println(e);
}
}
}

Dear sir in the above code it should throw NoSuchMethodException becouse showData() is not in class first that is on run time. But it is genrating a compile time error that can't resolve symbol why sir? and if it true then when does NoSuchMethodException is thrown?

with regard

Arun kumar maalik
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NoSuchMethodError happens at runtime when the .class files don't match the source code that the compiler saw. Imagine two classes where code in one class A calls a method in a second class B. First, compile both classes, then modify B to remove that method and recompile only B. Now when you run A, you'll see this exception.

In your case, the compiler can see the method is missing already, so it refuses to even compile the code.
 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks sir
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic