1public class Subtraction{
2 //simple subtraction method in Java
3 public static void main(String args[]){
4 int x = 3; // initializing first variable with a value
5 int y = 1; // initializing second variable
6
7 int answer = x - y; // new variable which is subtracting two variables x and y
8
9 System.out.println( x + " - " + y + " = " + answer );
10 // printing the answer of variables on the console
11 }
12}