📜  在java代码示例中减去两个变量

📅  最后修改于: 2022-03-11 14:52:30.683000             🧑  作者: Mango

代码示例1
public class Subtraction{
      //simple subtraction method in Java
    public static void main(String args[]){
        int x = 3; // initializing first variable with a value
          int y = 1; // initializing second variable
          
          int answer = x - y; // new variable which is subtracting two variables x and y
          
          System.out.println( x + " - " + y + " = " + answer );
          // printing the answer of variables on the console
    }
}