It seems I can not pass int value to Byte constructor except explicitly casting and using String? Well, if data type matters, why I can pass double value to Float constructor? please help me out.
In general, methods will automatically widen a primitive data type in order to match an expected argument type, but they will not narrow it (because this could result in a loss of precision). This automatic widening is called method-call conversion.
Note that a literal int value can be assigned to a narrower primitive type if it is within range. However, this narrowing is only for assignments -- not method arguments.
The Float constructor is a little unusual (compared to the other numeric wrappers) because it's overloaded to accept a float or a double. In the case of a double, the argument is converted to a float before wrapping. [ October 17, 2004: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, the permaculture playing cards