Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.unit0.net!news.netfront.net!not-for-mail From: Lothar Kimmeringer Newsgroups: comp.lang.java.programmer Subject: Re: Why not String compare? Date: Fri, 2 Sep 2016 21:54:49 +0200 Organization: Organization?! Only chaos here! Lines: 29 Message-ID: <1le6no2qsdcz4.dlg@kimmeringer.de> References: <33463070-424f-4fb0-956b-2849f1a400eb@googlegroups.com> <2dca46af-3b1f-4352-82c6-a413d9dac03c@googlegroups.com> Reply-To: news@kimmeringer.de NNTP-Posting-Host: 79.202.96.68 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1472846090 68229 79.202.96.68 (2 Sep 2016 19:54:50 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Fri, 2 Sep 2016 19:54:50 +0000 (UTC) User-Agent: 40tude_Dialog/2.0.15.1de Xref: csiph.com comp.lang.java.programmer:35537 Eric Douglas wrote: > Another example where I needed null to be valid in my custom > Comparable. I wrote a custom table (extends JTable). > Every cell in the table is a custom object. The cell class > has a getValue() and a compareTo(). getValue() may return > null because null has special meaning. You're only one step away from http://thedailywtf.com/articles/What_Is_Truth_0x3f_ Since you use customized Objects what prevented you from declaring a final static MyObject EMPTY_OBJECT = new MyObject() and do a == EMPTY_OBJECT instead of a == null? One day you will wonder why your application behaves strangely and after hours of debugging you find out that somewhere null is set where your special meaning wasn't intended. Cheers, Lothar -- Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions! --- news://freenews.netfront.net/ - complaints: news@netfront.net ---