Float.sum() in Java

Float.sum(): This method is available in java.lang.Float class of Java.

Syntax:

float java.lang.Float.sum(float a, float b)

This method takes two arguments of type float as its parameters. This method adds two float values together as per the + operator.

Parameters: Two parameters are required for this method.

a: the first operand.

b: the second operand.

Returns: The sum of a and b.

Approach

Java

public class FloatSum {
    public static void main(String[] args) {

        float a = 1919.6f, b = 9891.7f;
        System.out.println(Float.sum(a, b));

    }
}

Output:

11811.3

No comments:

Post a Comment