• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Anonymous inner class

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,

can anyone tell about, how to call a method inside anonymous class which is created in a method.


 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, do you mean calling a method belonging to the anonymous inner class, or calling another method from within an anonymous inner class?

Anyway, in both cases you just call it like any other method, as long as you have a reference to the object that you want to call the method on. For instance, within your Bar.foo() method you can just call:
It doesn't matter whether the Foo passed in was created as an anonynous inner class or a conventional class - either way you can still call the methods of the Foo interface on it.

If that doesn't answer the question, can you be a bit more specific about what you mean?
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic