Java Float - sum() Method
The java.lang.Float.sum() method is used to add two float values together as per the + operator.
Syntax
public static float sum(float a, float b)
Parameters
a |
Specify the first operand. |
b |
Specify the second operand. |
Return Value
Returns the sum of a and b.
Exception
NA.
Example:
In the example below, the java.lang.Float.sum() method is used to add two float values together as per the + operator.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating float values float x = 5.2f; float y = 10.2f; //printing the sum of float values System.out.println("x + y = " + Float.sum(x, y)); } }
The output of the above code will be:
x + y = 15.4
❮ Java.lang - Float