• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Clarification of Inner classes

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody
This is some discussion about Inner Class

There a 4 categories of "nested" classes
1)Top-level Nested classes and Interfaces
2)Non-Static Inner classes
3)Local classes
4)Anonymous classes
2,3,4 collectively known as "inner" classes
and Top-level Nested classes and Interfaces(1) are called static inner classes(I think so).
Am I right?
So if the question is that inner classes can be declared static so what we have to select either yes or no ? as inner classes(2,3,4 categories ) we cannot use a static keyword(they can be implicitly static if they are defined in static context(i.e static method,static initializer)
Please clear doubt and anwer this.I am little bit confused.
Thanx
Swati

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the answer is true.
the division is into top-level nested class and nested inner class only, the former being the static one.
the term inner class is used for all classes declared inside another class.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see this code compile and run fine.
note that i have used "static" key word with the class inner.
--------------------------------------
class outer{
static class inner{
}
}
public class outer1{
public static void main(String args[]){
}
}
---------------------------------------
Jaya Murugan
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the 4 types are called at Inner class. For top-level nested class (static inner class) rules are completely differnt that other 3. But still it is called as Inner class
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic