//CODE SNIPPET
boolean ShouldContinue1 = true;
List<String> b = new LinkedList();
input.useDelimiter("//s");
while (ShouldContinue1) {
String key = input.nextLine();
b.add(key);
int[] num = new int[(b.size()) / 2];
int[] denom = new int[(b.size()) / 2];
if (b_contains_string(key) == 1) {
// Problem
for (int i = 0; i < b.size() - 1; i++) {
if (i % 2 == 0) {
num[i / 2] = Integer.parseInt(b.get(i));
}
else if (i % 2 != 0) {
denom[i / 2] = Integer.parseInt(b.get(i));
}
}
}
else {
for (int i = 0; i < b.size(); i++) {
if (i % 2 == 0) {
//This line causes error
num[i / 2] = Integer.parseInt(b.get(i));
//
}
else if (i % 2 != 0) {
denom[i / 2] = Integer.parseInt(b.get(i));
//Ends
}
}
}
//The error message I get (with specified lines)
//Exception in thread "main" java.lang.NumberFormatException: For input string: "12 24 21 30" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at line
//
//
Not a duplicate, other posts ineffective in explaining my problem