I'm trying to implement an algorithm in one method that takes in two lists of type studentlist and I need to access the array from the constructor method, studentList to get the size and the student numbers to compare between lists.
e.g.
for (int i = 0; i < L1.studentID.length-1; i++) {
for (int j = 0; j < L2.studentID.length-1; j++) {
if (L1.studentID[i] = L2.studentID[j]) {
num++; }}}
Most of the constructor, and not including the 2nd one for accessing lists in a file instead of randomly generated:
studentID=new int[size];
boolean[] usedID=new boolean[IDrange];
for (int i=0;i<IDrange;i++) usedID[i]=false;
for (int i=0;i<size;i++) {
int t;
do {
t=(int)(Math.random()*IDrange);
} while (usedID[t]);
usedID[t]=true;
studentID[i]=t; }
Size (list.studentID.length or I could have used list.numberOfStudents which is built in) seems fine, but I'm having trouble with getting the elements of the array themselves. I figure I could just do list.studentID[i] but I get a 'type mismatch: cannot convert from int to boolean'.
Any ideas?