Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to add 2 numbers in java

public class AddTwoNumbers {

   public static void main(String[] args) {
        
      int num1 = 5, num2 = 15, sum;
      sum = num1 + num2;

      System.out.println("Sum of these numbers: "+sum);
   }
}



Output:
Sum of these numbers: 20
 
PREVIOUS NEXT
Tagged: #add #numbers #java
ADD COMMENT
Topic
Name
7+3 =