LongAdder floatValue() 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.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 does not accepts any parameter. Return value: The method returns a float value which represents the sum of this LongAdder Below programs demonstrate the above function: Program 1: Java // Java program to demonstrate // the LongAdder.floatValue() 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 final value System.out.println("After addition" + " of 6, value is: " + num); // Add 5 to it num.add(5); // Print the final value System.out.println("After addition" + " of 5, value is: " + num); // floatValue operation on num num.floatValue(); // Print after value System.out.println("Sum of LongAdder as float: " + num); } } Output: Initial value is: 0 After addition of 6, value is: 6 After addition of 5, value is: 11 Sum of LongAdder as float: 11 Program 2: Java // Java program to demonstrate // the LongAdder.floatValue() 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 final value System.out.println("After addition" + " of 10, value is: " + num); // Add 100 to it num.add(100); // Print the final value System.out.println("After addition" + " of 100, value is: " + num); // floatValue operation on num num.floatValue(); // Print after value System.out.println("Sum of LongAdder as float: " + num); } } Output: Initial value is: 0 After addition of 10, value is: 10 After addition of 100, value is: 110 Sum of LongAdder as float: 110 Comment More infoAdvertise with us Next Article LongAdder floatValue() 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 LongAccumulator floatValue() method in Java with Examples The java.LongAccumulator.floatValue() is an inbuilt method in java that returns the current value as a float after a widening primitive conversion. Syntax: public float floatValue() Parameters: This method does not accepts any parameter. Return Value: The method returns the current value as a float 2 min read Byte floatValue() method in Java with examples The floatValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as float. Syntax ByteObject.floatValue() Return Value: It return the value of ByteObject as float. Below is the implementation of floatValue() method in Java: Example 1: Java // J 2 min read Number.floatValue() method in java with examples The floatValue() method is an inbuilt method in Java from the java.lang.Number class. This method is used when we want to extract the value of a Number object as a float data type. This may involve rounding or truncation, because this method returns the numeric value of the current object converted 2 min read Short floatValue() method in Java with Example The java.lang.Short.floatValue() method of Short class is a built in method in Java which is used to return the value of the Short object as a float. Syntax: public float floatValue() Return type: It return the value of ShortObject as float. Below is the implementation of floatValue() method in Java 2 min read Float longValue() in Java with Examples The java.lang.Float.longValue() method in Float Class is a built in method in Java that returns the value specified by the calling object as long after type casting. Syntax: public long longValue() Parameters: It takes no parameters. Return type: It returns an long value i.e. the type casted value o 1 min read BigDecimal floatValue() Method in Java with Examples The java.math.BigDecimal.floatValue() converts this BigDecimal to a float. If this BigDecimal has too great magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. Note that even when the return value is finite, this conversion ca 2 min read AtomicLong floatValue() method in Java with examples The Java.util.concurrent.atomic.AtomicLong.floatValue() is an inbuilt method in java which returns the current value of the AtomicLong as a Float data-type after performing primitive conversion. Syntax: public float floatValue() Parameters: The function does not accepts any parameter. Return value: 1 min read DoubleAdder floatValue() method in Java with Examples The java.DoubleAdder.floatValue() is an inbuilt method in java that returns the sum() as an float after a narrowing primitive conversion. When the object of the class is created its initial value is zero. Syntax: public float floatValue() Parameters: This method does not accepts any parameter. Retur 1 min read Float intValue() method in Java with examples The intValue() method in Float Class is a built in method in Java that returns the value specified by the calling object as int after type casting. Syntax: public int intValue() Parameters: The function accepts no parameter. Return Value: It return the value of FloatObject as int. Below programs ill 2 min read Float hashCode() method in Java with examples The hashCode() method method in Float Class is a built-in method in Java that return the hashcode value of this Float object. Syntax: public int hashCode() Parameters: It takes no parameters. Returns: The function returns a hash code value for this object. Below is the implementation of hashCode() m 1 min read Like