Can somebody explain me the naming coventions related to Nested Classes? Some questions are specific when mentioning whether they are refering to static inner classes or non static inner classes or local classes or anonymous classes. But sometimes the questions simply refer as inner class (which is synonymous to non static inner classes - please correct me if i am wrong). Which one is being referred to in such a case? Am i right to say that static inner class is also called nested class? Thanx in advance!!
I *think* nested is just the general term for any class which is literally nested within something. I'd say a class is; top-level OR nested if nested then; member OR method-local OR anon if member then; static OR non-static (aka inner) Perhaps some beer swilling cowboy can confirm.
Martin, I hope you don't mind, I am going to repeat what you just said. A class is either (1) a top-level class or (2) a nested class. If a class is a nested class, it is either (1) a member class, (2) a local class or (3) an anonymous class. Member classes declared in classes are either non-static or explicitly declared static. Member classes declared in interfaces are implicitly static. Inner classes include non-static member classes, local classes and anonymous classes. ---- Definition: A nested class is any class whose declaration occurs within the body of another class or interface. Definition: A top level class is a class that is not a nested class. Definition: An inner class is a nested class that is not explicitly or implicitly declared static. ---- Beware: Some authors use the word �inner� where the JLS uses the word �nested�. Beware: Some authors use the terms �top-level nested� and �static inner�. These terms are not consistent with the usage of the JLS.
Joined: Apr 13, 2003
Thanx guys for the response.. I hope there is no confusion regarding this terminology in the exam
Joined: Mar 05, 2003
I hope there is no confusion regarding this terminology in the exam.