java short 写法_Java Short longValue()用法及代码示例
Short類的java.lang.Short.longValue()方法是Java中的內置方法,用于將Short對象的值返回為long。
用法
ShortObject.longValue()
返回值:它返回ShortObject的值,只要long。
下面是Java中longValue()方法的實現:
示例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
總結
以上是生活随笔為你收集整理的java short 写法_Java Short longValue()用法及代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS版小鸡模拟器怎样安装使用
- 下一篇: java美元兑换,(Java实现) 美元