Inconsistencies in TreeSet Interface
martinrb at google.com
Sat Oct 13 18:10:56 UTC 2018
core-libs-dev is the right mailing list.
The documentation could be improved, but it's nuanced - consider using a
TreeSet with a Comparator that accepts null.
On Sat, Oct 13, 2018 at 7:26 AM, Kishor Gollapalliwar <
kishor.gollapalliwar at gmail.com> wrote:
> Hello Everyone,
> Introduction : I’m an enthusiast java developer. I’m a newbie in this
> group, hence please ignore my nuisance and guide me towards right
> ## Problems Statement
> Treeset#add method documentations : “adds the specified element e to this
> set if the set contains no element e2 such that (e==null ? e2==null :
> > If we try to add “null” value, it will throws NullPointerException, hence
> > e and e2 can not be null.
> > And e.compareTo(e2) ==0 || compare(e, e2)==0, it will not add to
> > collection.
> Request you to help me understand if behavior of Treeset#add method is as
> expected, and differ with set interface documentation. We may have to
> consider to update method documentations, if behavior is expected.
> For more details I have attached the sample java application.
> I’ve tested the behavior on Orack JDK 8u181 (64 bit) and Open JDK 8u181.
> Thanks & Regards,
> *Kishor Golapelliwar,*
> The ability to convert ideas to things is the secret to outward success.
More information about the core-libs-dev