posted 18 years ago
Please find the detailed answer for clarification below:
Clarification 1:
If you define a class within another class then it is called a nested class.
class OuterClass {
...
class InnerClass {
...
}
}
It is come with two flavors. i) A nested class can be declared static (or not). A static nested class is called static nested class. ii)A nonstatic nested class is called an inner class.
class OuterClass {
...
static class StaticNestedClass {
...
}
class InnerClass {
...
}
}
So with the help of keyword static you can distinguish between static nested or inner class.
Clarification 2:
As the name suggest for local class (within the method) the scope of that class in limited within the method.
Local classes are declared within a block of code and are visible only within that block, just as any other method variable.
Clarification 3:
You can declare an inner class without naming it, called an anonymous class or you can say an anonymous class is a local class that has no name.
An anonymous class is generally used inside an expression and it does not have member scope, since it isn't visible to the enclosing class. Anonymous classes can make code difficult to read.
If you want to use an anonymous inner class, but it's too long to include inline, you can use a local class. A local class is like a named anonymous class. Typically, a local class is declared within a method or to initialize a field and, like an anonymous class, it also does not have member scope.
Clarification 4:
What exactly do you want for this clarification?
It clearly stated that �An inner class can be extended only if the outer class is extended.� means to extent an inner class you are bound to extend outer class.
Please let me know if you find anything wrong!!
Regards,
Sumit Jain