Reputation: 4647
Consider the following line of code:
java.lang.Number aNumber = new java.lang.Integer(1);
Now I am asking myself what would be the correct terms for both types (Number
and Integer
) regarding the variable aNumber
?
Would you call java.lang.Number
the "reference-type" and java.lang.Integer
simply the "type"?!
I could not find any earlier threads regarding this issue..
Thanks for your help!
Upvotes: 2
Views: 83
Reputation: 262484
Number
is the static (or declared) type, Integer
is the runtime (or dynamic, or actual) type.
The variable has type Number
, the instance contained in the variable has type Integer
.
A "reference type" is anything that inherits from Object
(including arrays). The opposite are the "primitive types" (like int
). Some languages also have "value types" (not Java, or maybe not yet).
Upvotes: 8