For a very basic example:
public class Human {
//human stuff
}
public class Developer extends Human{
//developer stuff
}
Why is Developer
an instance of Human
, but the class Developer
is not assignable to Human
?
Developer dev = new Developer();
System.out.println(dev instanceof Human); //true
System.out.println(Developer.class.isAssignableFrom(Human.class)); //false
But in addition to this: Human
is assignable to Developer
.
System.out.println(Human.class.isAssignableFrom(Developer.class)); //true
In normal English I would say that a Developer
object is assignable from a Human
class, not the other way around.
In normal English I would say, that a developer object is assignable from a human class, not the other way around.
And the problem is your usage of the words "object" and "class" here. It should be: a Human
variable is assignable from a value of type Developer
.
You assign a value to a variable from evaluating an expression.
See more on this question at Stackoverflow