• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

inner class  RSS feed

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!