Java Double longValue()方法及实例
Double类的 longValue() 方法是一个内置的方法,可以在类型转换后返回调用对象指定的长值。
语法
DoubleObject.longValue()
参数: 它不需要任何参数。
返回类型: 它返回一个 长值 ,即DoubleObject的类型转换值。
下面是上述方法的实现。
代码1 :
// Java Code to implement // longValue() method of Double classclass GFG { // Driver method public static void main(String[] args) { // creating a Double object Double d = new Double(1022); // longValue() method of Double class // typecast the value long output = d.longValue(); // printing the output System.out.println(output); }}
输出
1022
代码2 :
// Java Code to implement // longValue() method of Double classclass GFG { // Driver method public static void main(String[] args) { // creating a Double object Double d = new Double(-1023.23); // longValue() method of Double class // typecast the value long output = d.longValue(); // printing the output System.out.println(output); }}
输出
-1023
