thanks for your reply Campbell and Mike
. you mean to say that equals() method from Comparator could have been eliminated but it is just a reminder that in this case we can override equals() and how should we override it. Please explain it a little bit more because i dont think that in java there are things that have no reason. Everything thing contains some special meaning.Thanks again.