Re: java newbie question
Mark Space wrote:
dave wrote:
a Java type is a classification of what could potentially be bound
to a Java variable
This works for me. I also think of type as how the JVM will interpret
any given bit pattern to which the variable is bound.
Also, The Java class Class really describes types. Would it have made
more sense to call this class Type instead of Class?
Hmm, but ints, chars, booleans and all the other primitives are also
types, but I don't think that Class describes them. Class only deals
with Java objects (most of the language, admittedly) but there are a few
types it doesn't abstract.
Each of the wrapper types has a public static final TYPE field that
references the Class object for the corresponding primitive. For example:
"public static final Class<Integer> TYPE
The Class instance representing the primitive type int."
in class Integer. Class objects for primitives are important in some
reflection interfaces.
Also, generics are a type, but their type gets erased during
compilations. I don't think Class can represent the un-erased type.
I'm not sure generics count as a type, or anything else, in a running
program. They are effectively a form of compile-time assertion that
enables some extra checking.
Patricia