- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to add two integers
The + operator in Java is used to multiply two numbers. Read required numbers from the user using Scanner class and add these two integers using the + operator.
Example
import java.util.Scanner; public class AddinTwoNumbers { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter the value of the first number ::"); int a = sc.nextInt(); System.out.println("Enter the value of the first number ::"); int b = sc.nextInt(); int result = a+b; System.out.println("Sum of the given two numbers is ::"+result); } }
Output
Enter the value of the first number :: 5564 Enter the value of the first number :: 2234 Sum of the given two numbers is ::7798
- Related Articles
- C Program to Add two Integers
- Java program to swap two integers
- Java Program to add integers and check for overflow
- Java Program to add long integers and check for overflow
- Java program to add two matrices.
- Java Program to Add Two Numbers
- Java Program to Check Armstrong Number between Two Integers
- Java Program to Add the two Numbers
- Java Program to Add Two Binary Strings
- Java Program to Add Two Complex numbers
- How to write Java program to add two matrices
- Java Program to Add two Matrix using Iterative Approach
- Java Program to Add Two Matrix Using Multi-Dimensional Arrays
- Java Program to Add two Numbers without using Arithmetic Operator
- Java Program to concatenate a String and Integers

Advertisements