Print the Sum
Easyjava
Learn the Concept: First Java ProgramRead two integers and print their sum. This is the next step after printing fixed text: reading numbers and doing arithmetic.
Input: one line with two integers separated by a space.
Output: one line: their sum.
Example 1
Input
2 3
Output
5
Example 2
Input
100 -40
Output
60
- -1000000000 <= each integer <= 1000000000
Hint 1
sc.nextLong() reads one whitespace-separated number.
Hint 2
Use long so large values cannot overflow.
Read the two numbers as long values and print their sum. Using long keeps the result correct even when both inputs are near a billion.
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Hello in Two LinesEasy · javaSolve Problem
- Greet the UserEasy · javaSolve Problem
- About MeEasy · javaSolve Problem