My colleague told me that I should use float
whenever possible to reduce the object creation and increase the performance. Java silently converts float
to Float
(this needs some computational power) whenever necessary. So it seems to me that the only need for Float
is when one needs to use the object Float
very often instead of its primitive.
When looking at java.awt.Color
, it is using the Float
, perhaps unnecessarily.
When would one need to prefer Float
over float
in Java?