jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anonymous Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous Class" Watch "Anonymous Class" New topic

Anonymous Class

Pradeep Balasubramanian
Ranch Hand

Joined: Jun 16, 2008
Posts: 75

For the code above,
how to call the nowsee method in the main function ?

Regards,<br />Pradeep Balasubramanian<br /> <br />You have to grow from the inside out. None can teach you, none can make you spiritual. There is no other teacher but your own soul. <br /> <br />- Swami Vivekananda
Antonio Tercero
Ranch Hand

Joined: Jun 05, 2008
Posts: 110
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 )

wood burning stoves
subject: Anonymous Class
Similar Threads
Anonymous classes
interfaces used to work on my system but now they dont :)
Regarding Interface Concept
Why Casting w.r.t class and Interface differs?
Question on casting