How to create a Java scanner class to add two numbers?


http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html

import java.util.*;

public class ScannerClass
{

public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
System.out.print("1st num: ");
int num1=scan.nextInt();
System.out.println();
System.out.print("2nd num: ");
int num2=scan.nextInt();
int sum=num1+num2;
System.out.println();
System.out.println("Sum: "+sum);

}

}