aspose file tools
The moose likes Beginning Java and the fly likes Non-static inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Non-static inner classes" Watch "Non-static inner classes" New topic
Author

Non-static inner classes

Jason Stortz
Ranch Hand

Joined: Jan 11, 2001
Posts: 68
Take the following question:

My answer: False
I think it is this:
Non-static inner classes cannot have non-final static members.
Amy I thinking about this correctly? Or can anyone say this in a less confusing manner?
Thanks,
Jason

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9033
    
  10
Originally posted by Jason Stortz:
True or False:
Non-static inner classes cannot have static members?

Non-static inner classes cannot have non-final static members.

Inner classes cannot declare any static members unless they are compile-time constants and are primitives or Strings.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dean Jones Jr
Greenhorn

Joined: Mar 02, 2001
Posts: 6
For simplicity your question can be modified as
"inner classes cannot have static members" ? T/F
(because inner classes means non-static nested classes)
Inner classes are associated with the instance of the enclosing class. Hence, there cannot be static members in itself. However, as the sherrif said you can have compile time constants.
--
Originally posted by Jason Stortz:
[B]Take the following question:

My answer: False
I think it is this:
Non-static inner classes cannot have non-final static members.
Amy I thinking about this correctly? Or can anyone say this in a less confusing manner?
Thanks,
Jason
[/B]


Dean
 
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: Non-static inner classes
 
Similar Threads
Inner Class
Doubt In Static Memeber...Plz Help Me
Inner classes
Anonymous inner /static initializator
Non-static Inner Class