I'm having problems when taking a value out of a list and then casting it as an integer so I then can use it for different math functions, such as multiplication.
Current code :
int i = 0;
while(i < student_id.size()){
String finding = student_id.get(i).toString();
int s101 = ((Integer)score101.get(student101.indexOf(finding))); // <----this is where im having problems
System.out.println(student_id.get(i)+" "+names.get(i));
System.out.println("IR101 " +
score101.get(student101.indexOf(finding)) +
" IR102 " +
score102.get(student102.indexOf(finding)));
i++;
}
The error that im getting is java.lang.String cannot be cast to java.lang.Integer
. This confuses me because I thought it would have been an object. I have tried to convert it to an integer from both an object and a String but both throw up errors. How can I convert score101.get(student101.indexOf(finding))
to an int ?