Java.lang.Short.toString(short s) 方法
描述
java.lang.Short.toString(short s) 方法返回一个表示指定 short 的新 String 对象。 基数假定为 10。
声明
以下是 java.lang.Short.toString() 方法的声明。
public static String toString(short s)
参数
s − 这是要转换的short。
返回值
此方法返回指定短的字符串表示形式。
异常
NA
示例
下面的例子展示了 java.lang.Short.toString() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ShortDemo {
public static void main(String[] args) {
// create short object and assign value to it
short sval = 50;
Short shortValue = new Short(sval);
// returns a String object representing this Short value.
System.out.println("Value is = " + shortValue.toString());
// returns a String object representing the specified short
System.out.println("Value of specified short is = "
+ Short.toString((short)sval));
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Value is = 50 Value of specified short is = 50

