Java.lang.Double.longValue() Method

Advertisements


Description

The java.lang.Double.longValue() method returns the value of this Double as a long (by casting to type long).

Declaration

Following is the declaration for java.lang.Double.longValue() method

public long longValue()

Parameters

  • NA

Return Value

This method returns the double value represented by this object converted to type long.

Exception

  • NA

Example

The following example shows the usage of java.lang.Double.longValue() method.

package com.tutorialspoint;

import java.lang.*;

public class DoubleDemo {

   public static void main(String[] args) {

     /* returns the double value represented by this object
     converted to type long */
     Double obj = new Double("543267.90");
     long l = obj.longValue();
     System.out.println("Value = " + l);
    
     obj = new Double("30.0");
     l = obj.longValue();
     System.out.println("Value = " + l);
   }
}  

Let us compile and run the above program, this will produce the following result:

Value = 543267
Value = 30



Advertisements
Advertisements