Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

add two variables in java

public class Addition{
  	//simple addition method in Java
	public static void main(String args[]){
    	int x = 1; // initializing first variable with a value
      	int y = 3; // initializing second variable
      	
      	int sum = x + y; // new variable which is adding two variables x and y
      	
      	System.out.println( x + " + " + y + " = " + sum );
      	// printing the sum of variable on the console
    }
}
 
PREVIOUS NEXT
Tagged: #add #variables #java
ADD COMMENT
Topic
Name
1+2 =