Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35529
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why not String compare? |
| Date | 2016-09-01 10:17 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnnsg01f.456.avl@login.logic.tuwien.ac.at> (permalink) |
| References | (3 earlier) <e2bo9iF9m4nU1@mid.individual.net> <d9d392a6-7361-4743-aaef-22ec3d126722@googlegroups.com> <e2nb40F26seU1@mid.individual.net> <slrnnsd9q3.456.avl@login.logic.tuwien.ac.at> <e2oi5kFbhheU1@mid.individual.net> |
Robert Klemme <shortcutter@googlemail.com> wrote: > On 31.08.2016 11:45, Andreas Leitgeb wrote: >> Robert Klemme <shortcutter@googlemail.com> wrote: >>> The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) >>> for all x and y. (This implies that x.compareTo(y) must throw an >>> exception iff y.compareTo(x) throws an exception.) >> An equivalent "symmetry" could be expected from .equals, but isn't. > Not necessarily since the underlying concept is different That's not the point. If it *was* about symmetry (or anti- for compareTo) then both compareTo and equals would have to throw NPE for null argument, because obviously both throw NPE when called on a null reference. > You can reasonably say "that nothing is not equivalent to myself" If symmetry really was the requirement, then it would need to include symmetry to null.equals(...). It isn't, though. That .compareTo(null) throws NPE is *not* "for symmetry", but for a design decision, which defined compareTo to be NPE-symmetric. For equals a different decision was made. And both these decisions still make sense. I think, we're in "violent agreement" here, anyway.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 09:00 -0700
Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-26 18:49 +0200
Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 10:09 -0700
Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-26 22:48 +0200
Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 13:55 -0700
Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 17:29 -0400
Re: Why not String compare? Lew <lewbloch@gmail.com> - 2016-08-30 22:20 -0700
Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-31 08:17 +0200
Re: Why not String compare? Andreas Leitgeb <avl@logic.at> - 2016-08-31 09:45 +0000
Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-31 19:24 +0200
Re: Why not String compare? Andreas Leitgeb <avl@logic.at> - 2016-09-01 10:17 +0000
Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-09-02 18:29 +0200
Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 13:24 -0400
Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 10:48 -0700
Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 14:50 -0400
Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 12:19 -0700
Re: Why not String compare? Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-09-01 20:42 +0200
Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-01 17:57 -0400
Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 11:03 -0700
Re: Why not String compare? Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-09-02 21:54 +0200
csiph-web