Java snippet to add two numbers given by user

Table of contents

No heading

No headings in the article.

import java.util.Scanner;

public class SumOfTwoNumber {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter number 1");
        int num1 = scan.nextInt();

        System.out.println("Enter number 2");
        int num2 = scan.nextInt();

        int sum = num1 + num2;
        System.out.println("The sum is " + sum);
    }
}