This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous Class

 
Pradeep Balasubramanian
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

For the code above,
how to call the nowsee method in the main function ?
 
Antonio Tercero
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't call the method from main function.
Anonymous classes are used to pass a specific implementation as an argument of a method.
In your code, doStuff() method will be able to invoke nosee() method to perform some stuff but you can't access nosee() method from main.

You will understand better the concepts (why and when using anonymous classes) in chapter about Threads: there are a lot of examples regarding anonymous classes (implementation of a specific run() method from Runnable interface )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic