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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -