目录

short shortValue()

描述 (Description)

java.lang.Short.shortValue()方法将此Short的值作为short返回。

声明 (Declaration)

以下是java.lang.Short.shortValue()方法的声明

public short shortValue()

参数 (Parameters)

NA

返回值 (Return Value)

此方法在转换为short类型后返回此对象表示的数值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.Short.shortValue()方法的用法。

package com.iowiki;
import java.lang.*;
public class ShortDemo {
   public static void main(String[] args) {
      // create short object and assign value to it
      short sval = 50;
      Short sobj = new Short(sval);
      // returns short value of Short
      short shortValue = sobj.shortValue(); 
      // printing short value
      System.out.println("short value of given Short is = " + shortValue);
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

short value of given Short is = 50
↑回到顶部↑
WIKI教程 @2018