I am trying to assign a string value from an array to an integer via parseInt
and I'm getting this error. Any suggestions?
System.out.println("in the loop for loading info");
try
{
String testnumber = "1 ";
System.out.println("Numeric value of testnumber is:" + Integer.parseInt(testnumber.trim()));
System.out.println("String value from array is:" + Global.teamPlayerHandicap[row][0].trim());
int testvalue = Integer.parseInt(Global.teamPlayerHandicap[row][0].trim());
System.out.println("Test value:" + testvalue);
}
catch (NumberFormatException e)
{
System.out.println("This is not a number:" + Global.teamPlayerHandicap[row][0].trim() +"END");
System.out.println(e.getMessage());
}
Output:
in the loop for loading info
Numeric value of testnumber is:1
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "1"
String value from array is:1
This is not a number:1END
For input string: "1"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at com.snafilter.TGL.DoWorkTGL1.PopulateSubmitScoresInfo(DoWorkTGL1.java:1271)