Java Integer sum() Method
Example
Add two numbers:
public class Main {
public static void main(String[] args) {
int a = 5;
int b = 10;
System.out.println(Integer.sum(a, b));
}
}
Definition and Usage
The sum() method adds two int values and returns the result.
It gives the same result as the + operator.
Syntax
public static int sum(int a, int b)
Parameter Values
| Parameter | Description |
|---|---|
| a | Required. The first number. |
| b | Required. The second number. |
Technical Details
| Returns: | The sum of a and b, as an int. |
|---|
Related Pages
❮ Integer Methods