• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inner calss

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, anybody
inner calss can be static
inner class can't have static member
are they right
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this link for information on inner classes
http://www.go4java.20m.com/inner_classes.html
Hope it helps

Originally posted by foster cao:
hi, anybody
inner calss can be static
inner class can't have static member
are they right


 
Ranch Hand
Posts: 1246
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by foster cao:
hi, anybody
inner calss can be static
inner class can't have static member
are they right


no.. static inner class can have static memeber
thats top level nested class.
 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Foster,

Originally posted by foster cao:
inner calss can be static


yes,but then they become static inner classes(top level nested classes)


inner class can't have static member


Though they cannot have static members,
they can definitely have static final members,
which are compile time constants
HIH
somebody correct me if wrong
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Further, Local and Anonymous classes cannot be declared "Static" explicitly, the context in which they are declared dictates their type.
Hope this helps
Shyam
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a lot of discussion regarding the terms Inner class and nested class. I take inner class as non-static inner class(non static class defined inside a class), and nested class as staic class defined inside a top level class.
Inner classes can't be static as per my definition, if they are declared static, they will become nested class. Inner class can't have static members, but they can have constatnt defined as static final variables.
According to JLS 8.1.2
Inner Classes and Enclosing Instances
An inner class is a nested class that is not explicitly or implicitly declared static. Inner classes may not declare static initializers (�8.7) or member interfaces. Inner classes may not declare static members, unless they are compile-time constant fields (�15.28).
Please correct me if I am wrong.
--Farooq
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic