FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Windows XP
A DESCRIPTION OF THE PROBLEM :
int a = Integer.parseInt(args[0]) does not accept strings with "+" such as "+5"
I want to convert a string with a "+" in front of an integer into an "int" value using parseInt().. But strings such as "+35" cause a number format exception because of the "+" sign. This is absurd because "+35" as a number, is an integer value, just as "35" is. Negative signs are accepted by parseInt(), but not positive signs.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NumberFormatException: For input string "+9"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class EnterValues
{
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.println(" you have entered these values : " + a + " and " + b);
System.out.println(" area of a rectange is : " + a*b);
}
}
---------- END SOURCE ----------
ADDITIONAL OS VERSION INFORMATION :
Windows XP
A DESCRIPTION OF THE PROBLEM :
int a = Integer.parseInt(args[0]) does not accept strings with "+" such as "+5"
I want to convert a string with a "+" in front of an integer into an "int" value using parseInt().. But strings such as "+35" cause a number format exception because of the "+" sign. This is absurd because "+35" as a number, is an integer value, just as "35" is. Negative signs are accepted by parseInt(), but not positive signs.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NumberFormatException: For input string "+9"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class EnterValues
{
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.println(" you have entered these values : " + a + " and " + b);
System.out.println(" area of a rectange is : " + a*b);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-5017980 Allow signed positive integer to be parsed instead of a NumerFormatException
-
- Closed
-