Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 4
    According to the Java documentation, there is a difference between an inner class and a static nested class -- static nested classes don't have references to their enclosing class and are used primarily for organization purposes. You should see Jegschemesch's reply for a more in-depth description. Commented Nov 7, 2008 at 16:05
  • 1
    I think the semantic difference is mostly historical. When I wrote a C#->Java 1.1 compiler, the Java language reference was very explicit: nested class is static, inner class isn't (and thus has this$0). At any rate it's confusing and I'm glad it's no longer an issue. Commented Mar 26, 2009 at 13:41
  • 2
    The JLS defines "inner class" in docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.3 and that is why it is impossible to have a non-static "inner class" in Java. "Nested" is NOT "just another term to mean the same thing", and it is NOT TRUE that "an inner class is a class defined within a class (static or not)". That is INCORRECT information. Commented Jul 1, 2016 at 22:54