• Post Reply Bookmark Topic Watch Topic
  • New Topic

Use of an anonymous class  RSS feed

 
Sen George
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I happened to read that a typical use of an anonymous class is to override the method in a super class. Is that true?

If so, could anyone please describe a simple and practical working example?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A typical use for anonymous inner classes is in GUI programs using AWT/Swing, for event handlers. For example:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!