Subtyping in Java
In Java:
Stringis a subtype ofObject, because theStringclass is a subclass of theObjectclass.
intis not a subtype ofObject, because none of Java's primitive types are subtypes of any reference type.
StringBuilderis not a subtype ofString, because theStringBuilderclass is not a subclass of theStringclass.
HashMap<Candidate,Double>is a subtype ofMap<Candidate,Double>, because theHashMapclass implements theMapinterface and the type parameters match.
HashMap<Candidate,Double>is not a subtype ofMap<String,Ballot>, even though theHashMapclass implements theMapinterface, because the type parameters do not match.