File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous inner class

 
naveena kamsali
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • 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.


 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 1
  • Mark post as helpful
  • send pies
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic