java - Comparison against Double.TYPE and Double.class -
actually not question, since provide answer right away, don't fall same thing:
i wanted check (using reflection) if field
primitive or 1 of wrapper classes.
i checked using cl.isprimitive()
, comparisons c==boolean.type
, according debugger, boolean.type.tostring returns "boolean", instead of "boolean".
double.type == double.class
return true
.
double.class != double.type
return true
.
they (double.class , double.type) somehow represent same thing, don't ask me why...
if want compare against double
, compare against double.class
.
if want compare against double
, compare against double.class
or double.type
.
though haven't tested primitives, should same other primitives , wrappers.
i hope save @ least many minutes took me write this.
Comments
Post a Comment