Java Examples
Java ExamplesPrograms with output

Java Program to Sum of Two Value

import java.util.Scanner;

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

		Scanner scanner = new Scanner(;

		System.out.println("Enter first number: ");
		String num1 = scanner.nextLine();
		// getting value from user

		System.out.println("Enter second number: ");
		String num2 = scanner.nextLine();

		int nummber1 = Integer.parseInt(num1);
		int nummber2 = Integer.parseInt(num2);

		int sum = nummber1 + nummber2;

		System.out.println("Sum of two numbers: " + sum);
Enter first number: 10
Enter second number: 20
Sum of two Numbers: 30

Share this page on:

Was this page helpful ?

Let us know how we did!

Subscribe Email Updates

to get latest update