I'm having trouble finding information regarding this kind of subclassing/overriding in Java, which I see used a lot in Swing applications (event listeners and stuff like that):
// ...
SomeClass foo = new SomeClass() {
@Override
public String methodToOverride() { return ""; }
}
vs
class SubClass extends SomeClass {
@Override
public String methodToOverride() { return ""; }
}
// ...
SubClass foo = new SubClass();
Is the first case still a subclass of 'SomeClass', or is it the same type with an overridden method? In particular, what happens in the first case if inside methodToOverride() I call super.methodToOverride()? Will it call the original SomeClass' methodToOverride(), or SomeClass' parent methodToOverride()?