Alexander Danilou wrote:
Can you please tell me why Java considers A compatible with Face, but string is not?? Sorry if this question was already discussed in the past, I cannot find it.
JLS about legal casting (5.1.6 Narrowing Reference Conversions):
From any interface type J to any non-parameterized class type C that is not final.
Because the String class is
final, whereas A is NOT final. So, for the compiler, it could be possible that the class A is subclassed by an class implementing the Face interface
and extending the A class. That way the cast would be fine and even the runtime won't complain.