aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nested Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Nested Interface" Watch "Nested Interface" New topic
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Nested Interface
 
Similar Threads
inner class
Inner Access specifiers
Confused about Static Nested Class
problem with Toplevel Nested class
interface!!!