Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

subtract two variables in java

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
    }
}
 
PREVIOUS NEXT
Tagged: #subtract #variables #java
ADD COMMENT
Topic
Name
7+7 =