File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Implementing Interface Using Anonymous Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Implementing Interface Using Anonymous Class" Watch "Implementing Interface Using Anonymous Class" New topic
Author

Implementing Interface Using Anonymous Class

Sridhar Iyer
Greenhorn

Joined: Feb 21, 2011
Posts: 5

I don't seem to understand why "Cooking" is not being printed in the output for the following code. Can someone please explain me






Thanks
Sridhar
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

So your main method ends up executing the following line:


That creates a new Cookable object correctly. But nowhere do you tell it to execute its cook() method. If you want the output, try adding the line cookable.cook() after line 18.

By the way, the code would be a bit easier to read if you followed the Java conventions on capitalisation. The method Cooking() should really be cooking().
Sridhar Iyer
Greenhorn

Joined: Feb 21, 2011
Posts: 5

Thanks Matthew. Made the changes.

Thanks
Sridhar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing Interface Using Anonymous Class
 
Similar Threads
inner class query
Anonymous inner class
Anonymous Inner class
Instantiate an interface?
Compiling errata for K&B, SCJP 6