Home arrow static arrow Java Programming [Archive] - inner classes and interfaces
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - inner classes and interfaces
This topic has 6 replies on 1 page.

Posts:31
Registered: 7/7/04
inner classes and interfaces  
Aug 5, 2004 5:41 AM



 
Having a bit of a problem with the below code, it from an excersise in thinking in Jave. I've managed to create objects from an innner class before but when I try to base it on an interface it douse not work, pointers mutch appreciated:-
interface C8Q22Int {	class C8Q22Inner { }} class C8Q22 implements C8Q22Int {	public static void main( String[] args ) {		C8Q22 a = new C8Q22(); 		C8Q22.C8Q22Inner b = a.new C8Q22Inner();	}}


Ben
 

Posts:2,909
Registered: 13.8.2003
Re: inner classes and interfaces  
Aug 5, 2004 5:45 AM (reply 1 of 6)



 
What do you get when you compile that?
It seems valid.
 

Posts:31
Registered: 7/7/04
Re: inner classes and interfaces  
Aug 5, 2004 5:53 AM (reply 2 of 6)



 
C:\java>javac C8Q22.javaC8Q22.java:10: qualified new of static class                C8Q22.C8Q22Inner b = a.new C8Q22Inner();                                       ^1 error C:\java>
 

Posts:4,906
Registered: 23/07/02
Re: inner classes and interfaces  
Aug 5, 2004 5:57 AM (reply 3 of 6)



 
C8Q22Inner is implicitly public static. (Wow, we were talking about this yesterday in another thread). Remove the
a.
.
 

Posts:31
Registered: 7/7/04
Re: inner classes and interfaces  
Aug 5, 2004 6:01 AM (reply 4 of 6)



 
Are inner classes of interfaces always public static?
 

Posts:453
Registered: 11/6/04
Re: inner classes and interfaces  
Aug 5, 2004 6:05 AM (reply 5 of 6)



 
Any field in an interface is public static
 

Posts:4,906
Registered: 23/07/02
Re: inner classes and interfaces  
Aug 5, 2004 7:08 AM (reply 6 of 6)



 
Are inner classes of interfaces always public static?

Yes.
 
This topic has 6 replies on 1 page.