I need to enter a random amount of numbers from 0-500, once the return is an empty string, I need to exit the loop and do some calculations with the inputs. Here's my code so far:
String test = "";
while(test != null ){
String[] inputs = br.readLine().split("\\s+");
inputs[0] = test;
if (test != null){
inputs2[i] = Integer.parseInt(inputs[0]);
StatsPackage.inputs[i] = Integer.parseInt(inputs[0]);
}
i++;
}//end of while loop
Here is the error I keep getting:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at StatsPackage.main(StatsPackage.java:84)
Line 84 is this:
inputs2[i] = Integer.parseInt(inputs[0]);
any ideas?