What can I do with a Java Number? -
a function library returns number. can't convert usable ("cannot convert number int") , can't print using string.format. how handle number?
i can't convert usable
of course can!
void dosomething(number mynumber) { int intnumber = mynumber.intvalue(); double dblnumber = mynumber.doublevalue(); // useful } the idea behind number class give common superclass built-in numeric types. gives more flexibility in passing numbers around, decision on type use postponed until moment when numeric value needed.
this becomes useful when code data retrieval separate code consumes numeric data, because retrieval code can operate in terms of untyped numbers, without concerns specific type.
Comments
Post a Comment