Animal D = new Animal("Leo") {
@Override public void makeNoise() {
System.out.println("Roar!");
}
};
D.makeNoise();
So, when I asked what in this peaceful blue world this was, I was told that this was an anonymous class. I then looked up the related material and understood that they are classes with no name and are used only once. If that's the case, what is D? How come an anonymous class has a name 'D' here?
Secondly, do anonymous classes necessarily have to extend some other class (be it the cosmic Object itself)?
In my original code, Animal is actually an abstract class. What does this anonymous class have to do with Animal? Does it extend the Animal abstract class?