anne annetote wrote:yup exactly.
thanks for that.
i will try to figure this out.
thanks
Anne Saizan wrote:Thanks for the reply.
Set? how to use it.
That is unreliable; it will throw an Exception for anything but a Student object. The equals() method must accept any type of object, including null as an argument. And it seems odd that you are only using the ID as a test whether the Students are equal. Here is a recent thread where I wrote about equals methods. We have an FAQ and there are other good references, which you can find from this post.Ronald Castillo wrote: . . .
For your implementation would be to override equals() and hashCode() on your Student class
Could be as follow:
. . .
That is unreliable; it will throw an Exception for anything but a Student object. The equals() method must accept any type of object, including null as an argument. And it seems odd that you are only using the ID as a test whether the Students are equal. Here is a recent thread where I wrote about equals methods. We have an FAQ and there are other good references, which you can find from this post.