Java Integer.sum() – Examples

In this tutorial, we will learn about Java Integer.sum() method, and learn how to use this method to find the sum of two integers, with the help of examples.

sum(int a, int b)

Integer.sum(a, b) adds two integers a and b together as per the Arithmetic addition ( + ) operator.



The syntax of sum() method with the two integers as parameters is

Integer.sum(int a, int b)


aThe first operand for addition.
bThe second operand for addition.


The method returns value of type int.

Example 1 – sum()

In this example, we will take two integers and find their sum using Integer.sum() method.

Java Program

public class Example {
	public static void main(String[] args){
		int a = 5;
		int b = 8;
		int result = Integer.sum(a, b);
		System.out.println("Result of sum(" + a + ", " + b + ") = " + result);


Result of sum(5, 8) = 13


In this Java Tutorial, we have learnt the syntax of Java Integer.sum() method, and also how to use this method with the help of Java example programs.