The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

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.

Message:

U can instantiate intrfaces provided...

Posted by Siraj on September 26, 2000 at 7:22 AM

Hi shahul,
You can do sth like implementing interfaces in your code only when you are using anonymous classes, where you can use the syntax like this.
new someInterface(){
void doIt(){
System.out.println("done");
}
}
What you are really doing here is just implementing the interface. But since it is an anonymous class , the syntax is like that, which might have confused you. Otherwise, you are not permitted to do that directly even in JDK 1.2.
Hope that u'r doubt is cleared. If not, get back to me.

Thanx,
siraj.

> Could someone please explain to me why the code
> Runnable run = new Runnable() works? I used to believe that interfaces where implicitly abstract and therefore could not be instantiated; only implemented. Is Object somehow involved in this???

> Thanks,
> Shaul






Replies:

Sponsored Links



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