Reputation: 177
I'm new at android developement, new to Java too. Originally, I'm a C# and C++ programmer, so this is kind of suspect to me. I wrote this code
String[] teile = temp.split(" ");
int[] teileInt = new int[]
{
50, 50, 50, 50, 50, 50
} ;
for (int i = 0; i < teile.length; ++i) {
try {
Integer integer = new Integer(teile[i]);
//int d = Integer.parseInt(teile[i]);
}
catch (NumberFormatException ex)
{
Toast.makeText(this, teile[i] + getMessagesFromException(ex), Toast.LENGTH_SHORT).show();
}
//
}
Both expressions turn into the same Exception!
(Cant post an image)
The Toast says:
40null Invalid int: "40"
java.lang.NumberFormatException: Invalid
int: "40"
Im sorry, but I can' t figure out whats wrong... Is 40 not an Integer?
Upvotes: 1
Views: 435
Reputation: 39457
Try this. Integer integer = new Integer(teile[i].trim());
I assume you have a leading or a trailing space in teile[i]
.
Upvotes: 2