To my understanding, the following code should have printed true as output.
However, when I ran this code it is printing false.
From Java docs of Anonymous Classes 15.9.5. :
An anonymous class is always implicitly final
public class Test {
public static void main(String args[]) {
Object o = new Object() {
};
System.out.println("Annonymous class is final: " + Modifier.isFinal(o.getClass().getModifiers()));
}
}
Why this code is behaving like this ?