This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

nested class and inner class  RSS feed

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between nested class and inner class?
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This story about inner classes might give you some insight.
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a very simple yet complete summary of the picture about nested/inner classes:
nested classes

Regards
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that these terms are not always used consistently, especially in older material. (Surprisingly, Eckel's Thinking in Java is still not in agreement with the Java Language Specification.)

According to the current JLS...

"A nested class is any class whose declaration occurs within the body of another class or interface." (JLS 8)

"An inner class is a nested class that is not explicitly or implicitly declared static." (JLS 8.1.3)
[ August 27, 2006: Message edited by: marc weber ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!