searching objects in a vector according to an object data member
Hello,
I must admit that i am a rookie java programmer desperate for your help.
I have made a class that describes a college student.This is the part that matters for my problem
import java.util.*;
public class student
{
Integer idnumber;
Date dateofrecording;
String surname;
String name;
String fathersname;
String mothersname;
String placeofbirth;
Date dateofbirth;
Vector grades;
}
In an other class which is the office of the college, there is a "vector" called students in which the objects "student" will be kept.
I sort the students in this vector according to their idnumber using the Collections.sort(students, student.mitr) method where the comparator student.mitr is the following:
static public final Comparator mitr = new Comparator()
{
public int compare(Object o1, Object o2)
{
if(o1==o2) return 0;
student s1 = (student)o1;
student s2 = (student)o2;
return s1.idnumber.compareTo(s2.idnumber);
}
public boolean equals(Object obj)
{
return super.equals(obj);
}
};
I am using the : int index = Collections.binarySearch(students , idnum , student.mitr); (idnum is an Integer) to search for a student according to it's idnumber but it doesn't work.
I would be gratefull for your help.

