%uA0java.lang.Byte.shortValue()%uA0返回此字节为一个short值。
声明
以下是java.lang.Byte.shortValue()方法的声明
public short shortValue()
Overrides
shortValue 在Number%uA0类%uA0
参数
-
NA
返回值
此方法将返回该对象表示数值后转换为short型的值。
异常
-
NA
例子
下面的例子显示lang.Byte.shortValue()方法的使用。
package com.yiibai import java.lang.* public class ByteDemo { public static void main(String[] args) { // create 2 Byte objects b1, b2 Byte b1, b2 // create 2 short primitives s1, s2 short s1, s2 // assign values to b1, b2 b1 = new Byte("10") b2 = new Byte("-10") // assign short values of b1, b2 to s1, s2 s1 = b1.shortValue() s2 = b2.shortValue() String str1 = "short value of Byte " + b1 + " is " + s1 String str2 = "short value of Byte " + b2 + " is " + s2 // print s1, s2 values System.out.println( str1 ) System.out.println( str2 ) } }
让我们来编译和运行上面的程序,这将产生以下结果:
short value of Byte 10 is 10 short value of Byte -10 is -10