The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Instantiating interfaces

Posted by Jim Nichols on September 18, 2000 at 4:28 PM

This question interests me, too. I don't contest the current replies, but one reason I've had some trouble internalizing the use of anonymous inner classes is because you *appear* to instantiate an interface in certain cases. I refer to the following type of code:

ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {


No mention is ever made of implementing the ActionListener interface. This kind of shorthand can be counterproductive for someone trying to understand the code.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us