import java.io.*;
import java.lang.*;
class Addition
{
    public static void main(String args[])throws IOException
    {
        int n1,n2;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("enter first number: ");
        n1=Integer.parseInt(br.readLine());
        System.out.println("enter second number: ");
        n2=Integer.parseInt(br.readLine());
        n1+=n2;
        System.out.println("addition of two numbers is: "+n1);
    }
}

 OUTPUT:

Compilation : javac Addition.java

Execution : java Addition

enter first number:
10
enter second number:
20
addition of two numbers is: 30

 

Buy Head First Java

Best Book for Java

Beginner's Book