This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nested Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Nested Interface" Watch "Nested Interface" New topic
Author

Nested Interface

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

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, Certified Scrum Master
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: 9345
    
    2

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nested Interface
 
Similar Threads
Confused about Static Nested Class
inner class
Inner Access specifiers
problem with Toplevel Nested class
interface!!!