Integer.parseInt(\"-1000\"); returns -1000 as the output.
Integer.parseInt(\"+500\"); throws an exception.
How will I be able to re
The method is behaving as described in the documentation:
The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value.
You need to skip the first character if it is a + to do the parse correctly:
if (s.charAt(0) == '+') s = s.substring(1);
int val= Integer.parseInt(s);