Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35478
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why not String compare? |
| Date | 2016-08-26 17:29 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <npqcbm$bai$1@dont-email.me> (permalink) |
| References | <33463070-424f-4fb0-956b-2849f1a400eb@googlegroups.com> <e2ba8jF67mfU1@mid.individual.net> <1c9ad1a1-ee44-4a9f-a307-1dab14c4a921@googlegroups.com> <e2bo9iF9m4nU1@mid.individual.net> <d9d392a6-7361-4743-aaef-22ec3d126722@googlegroups.com> |
On 8/26/2016 4:55 PM, Eric Douglas wrote:
> [...] I am well aware the default for the Comparable class is to throw NPE if you try to compareTo(null). I'm asking why. This doesn't make sense. myString.compareTo(null) should return 1, just as myString.equals(null) returns false. Why shouldn't it make sense for everything to reutrn 1 (greater than) if you compare to a null? Is there another value to pass into the String.compareTo() to return the lowest possible String? This seems dumb that everyone who wants to compare Strings has to null check first.
Point #1: There is no "Comparable class"; Comparable is an interface
implemented by many classes (the Javadoc lists one hundred fifty-two),
each with its own behaviors.
Point #2: Comparable has no "default" behavior at all, not even with
the introduction of `default' methods for Java 1.8 interfaces.
Point #3: This whole thread ultimately boils down to "I'm unhappy
with the way java.lang.String implements Comparable." Okay, fine: I'm
unhappy with some pieces of Java, too (that's not one of them). Express
your unhappiness, stop whining, and get on with your life. Or go look
up Guy Steele and give *him* a tongue-lashing.
--
esosman@comcast-dot-net.invalid
The Tooth Fairy has gone high-tech, now pays in Bitecoin.
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