Online Java Compiler By
JavaTpoint.com
public class Double_longValueMethodExample1{ public static void main(String[] args) { double d1 = 655; Double d2 = new Double(d1); // return the long value of double object Long val1 = d2.longValue(); System.out.println("1. "+"Long value for "+d1+" = "+val1); Double d3 = new Double(6575876985679.675); System.out.println("2. "+"Long value for "+d3+" = "+d3.longValue()); //passing negative integer Double d4 = new Double(-86776985679.88675); System.out.println("3. "+"Long value for "+d4+" = "+d4.longValue()); } }
Output