Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Interface Using Anonymous Class

 
Sridhar Iyer
Greenhorn
Posts: 5
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Matthew. Made the changes.

Thanks
Sridhar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic