0

why not use extends :

public TreeSet(Comparator<? extends E> comparator)

thank you !

search stackoverflow ,but not answer。

startjava
  • 33
  • 5
  • 1
    https://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super – Eng.Fouad Mar 06 '20 at 06:50
  • 1
    the comparator needs to read elements (not *write*). Example, if you have a set of `Number`, a comparator for `Object` would work, but not a comparator for `Integer` (set could contain a `Double`) – user85421 Mar 06 '20 at 06:58

0 Answers0