import java.io.*;
import java.lang.*;
class Sub
{
    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("Subtraction of two given numbers is: " +n1);

    }
}

 OUTPUT:

Compilation: javac Sub.java
Run Program: java Sub
Enter first number:
10
Enter second number:
5
Subtraction of two given numbers is: 5

 

Buy Head First Java

Best Book for Java

Beginner's Book