java short 写法_Java Short longValue()用法及代码示例
Short類的java.lang.Short.longValue()方法是Java中的內(nèi)置方法,用于將Short對(duì)象的值返回為long。
用法
ShortObject.longValue()
返回值:它返回ShortObject的值,只要long。
下面是Java中l(wèi)ongValue()方法的實(shí)現(xiàn):
示例1:
// Java code to demonstrate
// Short longValue() method
class GFG {
public static void main(String[] args)
{
// Short value
Short a = 17;
// wrapping the Short value
// in the wrapper class Short
Short b = new Short(a);
// longValue of the Short Object
long output = b.longValue();
// printing the output
System.out.println("Long value of "
+ b + " is : " + output);
}
}
輸出:
Long value of 17 is : 17
示例2:
// Java code to demonstrate
// Short longValue() method
class GFG {
public static void main(String[] args)
{
String value = "17";
// wrapping the Short value
// in the wrapper class Short
Short b = new Short(value);
// longValue of the Short Object
long output = b.longValue();
// printing the output
System.out.println("Long value of "
+ b + " is : " + output);
}
}
輸出:
Long value of 17 is : 17
總結(jié)
以上是生活随笔為你收集整理的java short 写法_Java Short longValue()用法及代码示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS版小鸡模拟器怎样安装使用
- 下一篇: 安装在电视上的路由器怎样可以开启路由器连