<p>各种数字类型转换成字符串型:</p><p>String s = String.valueOf( value); // 其中 value 为任意一种数字类型。</p><p>字符串型转换成各种数字类型:</p><pre class="brush:java;toolbar:false">Strings=&quot;169&quot;; byteb=Byte.parseByte(s); shortt=Short.parseShort(s); inti=Integer.parseInt(s); longl=Long.parseLong(s); Floatf=Float.parseFloat(s); Doubled=Double.parseDouble(s);</pre><p>数字类型与数字类对象之间的转换:</p><pre class="brush:java;toolbar:false">byteb=169; Bytebo=newByte(b); b=bo.byteValue(); shortt=169; Shortto=newShort(t); t=to.shortValue(); inti=169; b=bo.byteValue(); shortt=169; Shortto=newShort(t); t=to.shortValue(); inti=169; Integerio=newInteger(i); i=io.intValue(); longl=169; Longlo=newLong(l); l=lo.longValue(); floatf=169f; Floatfo=newFloat(f); f=fo.floatValue(); doubled=169f; DoubledObj=newDouble(d); d=dObj.doubleValue();</pre>
T:0.006742s,M:245.05 KB
返回顶部 留言