Add Two Numeric Strings
Mediumjava
Two numbers arrive as text (String). Convert each to an int and print their sum. A cast like (int) does not work here — you must parse.
Input: two lines, each a whole number written as text.
Output: one line — the sum of the two numbers.
Example 1
Input
12 30
Output
42
- -1000000000 <= each number <= 1000000000
Hint 1
Integer.parseInt(s) converts a numeric String to an int.
Hint 2
Use long if you want to be safe with values near a billion.
String and int are unrelated types, so (int) cannot convert between them. Integer.parseInt (or Long.parseLong) reads the digits of the text and produces a real number you can add.