object - Java: Should I use float or Float? -
this question has answer here:
- when use wrapper class , primitive type 9 answers
my colleague told me should use float whenever possible reduce object creation , increase performance. java silently converts float float (this needs computational power) whenever necessary. seems me need float when 1 needs use object float instead of primitive.
when looking @ java.awt.color, using float, perhaps unnecessarily.
when 1 need prefer float on float in java?
the object float
can set null represent value unknown.
primitive float
guaranteed have value.
there overhead on autoboxing, negligible. still must allocate space primitive there nothing gain there.
Comments
Post a Comment