• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous Inner Class

 
Sen George
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following code listing, please explain why the output " prAnon procedure" is not generated.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sen,
Where does prAnon get called? It's just a method. If it doesn't get called, it doesn't print anything.
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
moved to the intermediate forum
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a guess on what might be causing the misunderstanding...

In the syntax for an anonymous inner class, the constructor call is followed by the anonymous class definition -- not the body of the constructor.

So the code within the braces does not execute with "new."
 
Sen George
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I incorporate a call to invoke the method defined in an anonymous class?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic