Which of the two statements is true and why? Can somebody please explain 1. A nested class is any class that is declared within the body of another class or interface. 2. A nested class cannot be declared within the body of another class or interface.
nested classes are inner classes.... inner classes are declares within a class or an interface... you can declare inner classes inside methods as well...
Originally posted by Charith Fernando: nested classes are inner classes...
Not quite. According to the JLS...
"A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class." (Ref JLS - 8.)
And...
"An inner class is a nested class that is not explicitly or implicitly declared static." (Ref JLS - 8.1.3.)
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org