Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to add two numbers in java

import java.util.*;
public class Add
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter 2 numbers");
    num1=sc.nextInt();
    num2=sc.nextInt();
    int sum=num1+num2;
    System.out.println("The sum of the two numbers is: "+sum);
  }
}
Comment

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
Comment

how to plus two numbers in java

public class Rohit {
    public static void main (String[]args){

        int a=5;
        int b=6;
        int sum =a+b;

        System.out.println("The sum is: "+sum);
    }
    
}
Comment

how to plus two numbers in java

public class Rohit2 {
    public static void main (String[]args){

        int a=5;
        int b=6;
        int sum =a+b;

        System.out.println("The sum is: "+sum);
    }
    
}
Comment

how to plus two numbers in java

public class Rohit2 {
    public static void main (String[]args){

        int a=5;
        int b=6;
        int sum =a+b;

        System.out.println("The sum is: "+sum);
    }
    
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to read text file as variable in java 
Java :: how to make popupwindow background blur in android 
Java :: Syntax of how to create ArrayList in Java 
Java :: can i have both java7 and java 11 in mac 
Java :: activityViewModels 
Java :: java queue implementation 
Java :: boolean in java 
Java :: arraylist vs vector in java 
Java :: objectmapper in java 8 
Java :: how to draw a triangle in java 
Java :: how to initialize char in java 
Java :: spring security after login redirect 
Java :: java get element occurrences in a list java 
Java :: how to find armstrong numbers in java 
Java :: Java How to use List? 
Java :: Arraylist in java by dc 
Java :: android studio clock bar change color programmatically 
Java :: debug cxf 
Java :: java add a list to a list 
Java :: java android build secret keys 
Java :: integer parse int exceptions 
Java :: android java change text value 
Java :: Java Add Elements to an ArrayList 
Java :: java bogosort 
Java :: iterative inorder traversal 
Java :: draw triangle in android studio xml 
Java :: java inner method 
Java :: check if input is empty java 
Java :: Java comment vérifier une égalité de String 
Java :: android studio SELECT * FROM table 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =