In this post, I will explain about a Java program to subtract any two numbers with an example and program output.
This is a very basic program in Java programming language. If you are a Java beginners or want to start learning Java programming language, then this program will help you to understand the basic Java programming.
Before executing this program I assume you have configured Java in your computer.
Copy the below program and create a file “SubstractProgram.java” and execute it to subtract any two numbers.
public static void main(String args)throws Exception
BufferedReader br= new BufferedReader( new InputStreamReader(System.in));
System.out.println("Enter any two numbers to Substract:");
x = x-y;
System.out.println("\nSubstraction of two numbers:"+ z);
Enter any two numbers to Substract:
Sum of two numbers:30