Addition Of Two Numbers In Java
Add Two Numbers in Java Overview How to add two numbers in Java will show addition of given two numbers. Scope of Article This article provides information about addition of two numbers in Java. Examples of different ways of summing are given. Uses the ( + ) operator to add two numbers. Let's see how we can add two numbers in Java. Method 1: Sum of two numbers This is the simplest way to add two numbers in Java. We will initialize and declare the value in the program itself. Here no input value is taken from the user. Example : class Main { public static void main (String[] args) { int e1 , f2 , sum ; e1 = 100 ; // I nitialize f2 = 200 ; sum = e1 + f2 ; // Addition operation System.out.println( " Addition of " +e1+ " + "+f2+" = " +sum); } } Output A ddition of 100 + 200 = 300 Explanation In the above program we have taken three vari