Hi William,
Below is the explanation . I hope you will understand clearly after reading this . if you still have any confusion please let me know..
Inner or non-static nested : :
the term Inner here to represent inner classes that are not :
Static
Method-local
Anonymous
Example::
class MyOuter {
private int x = 7;
// inner class definition i.e not static
class MyInner {
public void seeOuter() {
System.out.println("Outer x is " + x);
}
} // close inner class definition
} // close outer class
Nested or static nested ::
Static nested classes referred to as static inner classes, but they really aren't inner classes at all, by the standard definition of an inner class.
While an inner class (regardless of the flavor) enjoys that special relationship with the outer class (or rather the instances of the two classes share a relationship), a static nested class does not.
Actually there is no static class at all.it’s like a static member of a class in which it’s declared.
Example :
class BigOuter {
static class Nested { }
}
Amonymous Class ::
inner classes declared without
any class name at all (hence the
word anonymous).
you can define these classes not just within a method, but even within an argument to a method.
Example ::
class Popcorn {
public void pop() {
System.out.println("popcorn");
}
}
class Food {
Popcorn p = new Popcorn() {
public void pop() {
System.out.println("anonymous popcorn");
}
};
}
Laocal or non-static nested in method's scope ::
Any class i.e declared within the scope of a method .even though we can have these classes in loops any block etc.
Example ::
class MyOuter2 {
private
String x = "Outer2";
void doStuff() {
class MyInner {
public void seeOuter() {
System.out.println("Outer x is " + x);
} // close inner class method
} // close inner class definition
} // close outer class method doStuff()
} // close outer class
Regards…..