| Author |
Nested Interface
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hi all, I have a doubt regarding inner classes and interfaces. Can anyone please clarify this to me. Consider the below code and tell me why it gives error in the lines commented, Thanks in advance. Regards, Jothi Shankar Kumar. S
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Rajesh Kadle
Greenhorn
Joined: Sep 06, 2004
Posts: 26
|
|
In both cases static reference is made to non-static fileds, hence the compiler error. Static context relates to class, it works with class. It has no reference like this or super, so we cant access the non-static fields from static context. Other way, accessing static fields from non-static context is allowed as each instance is related to the class.
|
-Raj
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hai, I just want to know if in the above code, the line, interface StaticMemberInterface_1{int kk = 2000;} Is kk implicitly static? Regards, Jothi Shankar Kumar. S
|
 |
Rajesh Kadle
Greenhorn
Joined: Sep 06, 2004
Posts: 26
|
|
|
yes, all fields inside an interface are implicitly static and final.
|
 |
 |
|
|
subject: Nested Interface
|
|
|