LongAdder increment() method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.increment() is an inbuilt method in java that increases the value by 1. Syntax: public void increment() Parameters: The function does not accepts any parameter. Return value: The method do not returns any value. Below programs demonstrate the above function: Program 1: Java // Java program to demonstrate // the LongAdder.increment() method import java.lang.*; import java.util.concurrent.atomic.LongAdder; public class GFG { public static void main(String args[]) { // Initialized with 0 LongAdder num = new LongAdder(); // Print the initial value System.out.println("Initial value is: " + num); // Add 6 to it num.add(6); // Print the new value System.out.println("After addition" + " of 6, value is: " + num); // Increment operation on num num.increment(); // Print after increment System.out.println("After increment, " + " value is: " + num); } } Output: Initial value is: 0 After addition of 6, value is: 6 After increment, value is: 7 Program 2: Java // Java program to demonstrate // the LongAdder.increment() method import java.lang.*; import java.util.concurrent.atomic.LongAdder; public class GFG { public static void main(String args[]) { // Initialized with 0 LongAdder num = new LongAdder(); // Print the initial value System.out.println("Initial value is: " + num); // Add 10 to it num.add(10); // Print the new value System.out.println("After addition" + " of 10, value is: " + num); // Increment operation on num num.increment(); // Print after increment System.out.println("After increment, " + " value is: " + num); } } Output: Initial value is: 0 After addition of 10, value is: 10 After increment, value is: 11 Comment More infoAdvertise with us Next Article LongAdder increment() method in Java with Examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-LongAdder +1 More Practice Tags : JavaMisc Similar Reads LongAdder intValue() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.intValue() is an inbuilt method in java that returns the sum as a int value. When the object of the class is created its initial value is zero. Syntax: public int intValue() Parameters: The function does not 2 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 LongAdder sum() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.sum() is an inbuilt method in java that returns the sum. Syntax: public long sum() Parameters: The function does not accepts any parameter. Return value: The method returns the current sum. Program below demo 2 min read LongAdder reset() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.reset() is an inbuilt method in Java that resets the sum to zero. When the object of the class is created its initial value is zero. Syntax: public void reset() Parameters: The function does not accepts any p 2 min read LongAdder toString() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.toString() is an inbuilt method in Java that returns the String representation of this LongAdder. When the object of the class is created its initial value is zero. Syntax: public String toString() Parameters 2 min read LongAdder floatValue() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.floatValue() is an inbuilt method in java that returns the sum as a float value. When the object of the class is created its initial value is zero. Syntax: public float floatValue() Parameters: The function d 2 min read LongAdder decrement() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.decrement() is an inbuilt method in java that reduces the value by 1. Syntax: public void decrement() Parameters: The function does not accepts any parameter. Return value: The method do not returns any value 2 min read LongAdder longValue() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.longValue() is an inbuilt method in java that returns the sum(). This method is equivalent to the sum() method. When the object of the class is created its initial value is zero. Syntax: public long longValue 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 LongAdder sumThenReset() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.sumThenReset() is an inbuilt method in Java that is equivalent to sum() then reset() function. Firstly, the sum is calculated and then it is reset to the value 0. When the object of the class is created its i 2 min read Like