• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

inner class

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


A inner class may be declared static.



Only a non-static nested class in known as inner class.

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

A inner class may be declared static.



In this case it will be not inner but top-level nested class, I guess. The point is the inner class can access instance members of outer and top-level nested class cannot.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the difference between an inner class and nested class?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nested Classes are defined with Static keyword & are considered as Top Level Classes. They don't require the instance of outer class to create their own instance, whereas an inner class is tied to the instance of outer class.

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


What's the difference between an inner class and nested class?


Here is my contribution to the world of confusion: http://qa.jtiger.org/GetQAndA.action?qids=67&showAnswers=true


Nested Classes are defined with Static keyword & are considered as Top Level Classes.


This is false, a nested class and a top-level class are mutually exclusive entities. A class cannot be nested and top-level at the same time.
 
reply
    Bookmark Topic Watch Topic
  • New Topic