java.lang.Short.parseShort(String s)方法实例
由 月堂海冰 翻译整理
注: 由于水平有限,欢迎指正。转载请务必注明出处。
width="728" height="90" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" id="aswift_0" name="aswift_0" style="box-sizing: border-box; left: 0px; position: absolute; top: 0px;">
id="iframeu1064372_0" src="http://pos.baidu.com/acom?rdid=1064372&dc=2&di=u1064372&dri=0&dis=0&dai=1&ps=378.11111405455046x287&dcb=BAIDU_UNION_define&dtm=BAIDU_DUP_SETJSONADSLOT&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1457082821195&ti=java.lang.Short.parseShort(String%20s)%E6%96%B9%E6%B3%95%E5%AE%9E%E4%BE%8B%20-%20java.lang&ari=1&dbv=2&drs=1&pcs=1224x623&pss=1224x1663&cfv=0&cpl=4&chi=1&cce=true&cec=UTF-8&tlm=1457082821<u=http%3A%2F%2Fwww.yiibai.com%2Fjava%2Flang%2Fshort_parseshort.html<r=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DooRqy6jw4luGCHUIp2s4be0qqs9Kd5y3MxqJ6FR0_OCyNBPNRXZ_XaK13nW4VtYRl_Frro6m47XcSTXO9Ybdb_%26wd%3D%26eqid%3Df463faf90001c75a0000000556d9517c&ecd=1&psr=1366x768&par=1366x728&pis=-1x-1&ccd=24&cja=false&cmi=6&col=zh-CN&cdo=-1&tcn=1457082821&qn=23ab223194b402cf&tt=1457082821172.26.1231.1234" width="728" height="90" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="box-sizing: border-box; border-width: 0px; border-style: initial; vertical-align: bottom; margin: 0px;">
java.lang.Short.parseShort(String s) 方法解析字符串参数为有符号的十进制short值。
声明
以下是java.lang.Short.parseShort() 方法的声明
public static short parseShort ( String s ) throws NumberFormatException
参数
返回值
此方法返回由十进制参数表示的short值。
异常
例子
下面的例子显示java.lang.Short.parseShort()方法的使用。
package com . yiibai ;
import java . lang .*;
public class ShortDemo {
public static void main ( String [] args ) {
String str = "250" ;
// returns signed decimal short value of string
short shortValue = Short . parseShort ( str );
// prints signed decimalshort value
System . out . println ( "Signed decimal short value for given String is =
" + shortValue );
}
}
让我们来编译和运行上面的程序,这将产生以下结果:
Signed decimal short value for String is = 250