File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous Class" Watch "Anonymous Class" New topic
Author

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 )


SCJP 5, SCWCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anonymous Class