Reputation: 139
The Java Language Specification 20, Section 4.10. Subtyping states that
The subtypes of a type T are all types U such that T is a supertype of U, and the null type. We write T
<:
S to indicate that that the subtype relation holds between types T and S.
Does this mean, that the null type is a subtype of all primitive types? And if yes, are there any practical consequences?
I'm writing a library to parse and analyze java code, so should I treat null
as a subtype of, say, int
? Or does it not matter at all?
Upvotes: 5
Views: 150