add two variables in java

Solutions on MaxInterview for add two variables in java by the best coders in the world

showing results for - "add two variables in java"
Mads
28 Jun 2018
1public class Addition{
2  	//simple addition method in Java
3	public static void main(String args[]){
4    	int x = 1; // initializing first variable with a value
5      	int y = 3; // initializing second variable
6      	
7      	int sum = x + y; // new variable which is adding two variables x and y
8      	
9      	System.out.println( x + " + " + y + " = " + sum );
10      	// printing the sum of variable on the console
11    }
12}