DoubleAdder longValue() method in Java with Examples Last Updated : 28 Jan, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.DoubleAdder.longValue() is an inbuilt method in java that returns the sum() as a long after a narrowing primitive conversion. When the object of the class is created its initial value is zero. Syntax: public long longValue() Parameters:Return value: This method returns the numeric value represented by this object after conversion to long data type. Below programs illustrate the above method: Program 1: Java // Program to demonstrate the longValue() method import java.lang.*; import java.util.concurrent.atomic.DoubleAdder; public class GFG { public static void main(String args[]) { DoubleAdder num = new DoubleAdder(); // add operation on num num.add(42); num.add(10); // longValue operation on variable num num.longValue(); // Print after longValue operation System.out.println("the value after longValue() is: " + num); } } Output: the value after longValue() is: 52.0 Program 2: Java // Program to demonstrate the longValue() method import java.lang.*; import java.util.concurrent.atomic.DoubleAdder; public class GFG { public static void main(String args[]) { DoubleAdder num = new DoubleAdder(); // add operation on num num.add(62); // longValue operation on variable num num.longValue(); // Print after longValue operation System.out.println("the value after longValue() is: " + num); } } Output: the value after longValue() is: 62.0 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAdder.html#longValue-- Comment More infoAdvertise with us Next Article DoubleAccumulator longValue() method in Java with Examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-Functions Java-DoubleAdder Practice Tags : JavaMisc Similar Reads DoubleAccumulator longValue() method in Java with Examples The Java.DoubleAccumulator.longValue() is an inbuilt method in java that returns the current value as a long after a narrowing primitive conversion. It means the initial datatype is double which is explicitly converted into type long. Syntax: public long longValue() Parameters: The method does not a 2 min read Byte longValue() method in Java with examples The longValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as long. Syntax ByteObject.longValue() Return Value: It return the value of ByteObject as long. Below is the implementation of longValue() method in Java: Example 1: Java // Java c 2 min read LongAdder doubleValue() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.doubleValue() is an inbuilt method in java that returns the sum as a double value. When the object of the class is created its initial value is zero. Syntax: public double doubleValue() Parameters: The functi 2 min read Double longValue() in Java with Examples The longValue() method of Double class is a built in method to return the value specified by the calling object as long after type casting. Syntax DoubleObject.longValue() Parameters : It takes no parameters. Return type : It returns an long value i.e. the type casted value of the DoubleObject. Belo 1 min read DoubleAdder intValue() method in Java with Examples The java.DoubleAdder.intValue() is an inbuilt method in java that returns the sum() as an int after a narrowing primitive conversion. When the object of the class is created its initial value is zero. Syntax: public int intValue() Parameters: This method does not accepts any parameter. Return Value: 1 min read LongAdder add() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.add() is an inbuilt method in java that adds the given value. Syntax: public void add(long x) Parameters: The function accepts a single parameter x that specifies the value to be added. Return value: The meth 2 min read Like