Variable of an object in an array compared to an element of another array?

I have an array of objects with four fields and another array of ints. I'm having trouble trying to see if each of the elements of the int array are equal to a certain (the same) field of each of the objects in the object array but I keep getting errors.

if (studentIDNumbers[index] != student[index2].getStudentID())

doesn't seem to work..

studentIDNumbers is the array of ints and student[] is the object array. getStudentID is the accessor method for the int field of the object.

Anyone know what I'm doing wrong?