Sometimes I find class codes with inner class , such as:
class ClasseExterna {
private int a = 10;
// ...
class InnerClass {
public void accessOuter() {
System.out.println("Outra classe " + a);
}
// ...
}
}
I always wonder:
Why and when should I use inner class ? I have not yet come across a situation where there was no other alternative.