Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24935
| Date | 2013-08-08 20:45 +0100 |
|---|---|
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
| Organization | Trollbusters 3 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Cost of creating objects? |
| References | (5 earlier) <ktuq3e$amp$1@dont-email.me> <lvd2pobne0.fsf@saunalahti.fi> <Bt2dnfpJy-4rwp7PnZ2dnUVZ7sOdnZ2d@bt.com> <lv61vgs13m.fsf@saunalahti.fi> <5203ae61$0$291$14726298@news.sunsite.dk> |
| Message-ID | <XMGdnV9fCM_yaJ7PnZ2dnUVZ7oidnZ2d@bt.com> (permalink) |
On 08/08/13 15:42, Arne Vajhøj wrote: > On 8/8/2013 10:34 AM, Jukka Lahtinen wrote: >> lipska the kat <"nospam at neversurrender dot co dot uk"> writes: >>> On 08/08/13 09:24, Jukka Lahtinen wrote: >> >>>> Value val = map.get(key); >>>> if (val != null // usually false >> >>> I think (null != val ... ) is better. >> >> Why? I see no real difference. >> If you are thinking about NullPointerException, it is not thrown by >> this kind of comparison, where you just check equality to null without >> refering any possible members of val. > > The trick sometimes called Yoda condition is from C/C++ where > you could intend to write: > if(val == null) > and end up writing: > if(val = null) > and not get a compile error but instead a different semantics than > expected. > > Writing: > if(null == val) > avoid that risk as: > if(null = val) > will give a compile error. > > But Java is different. It is, damn that C lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun GNU/Linux user #560883 - http://www.linuxcounter.net
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Cost of creating objects? Sebastian <news@seyweiler.dyndns.org> - 2013-08-07 09:44 +0200
Re: Cost of creating objects? Donkey Hottie <donkey@fredriksson.dy.fi> - 2013-08-07 13:02 +0300
Re: Cost of creating objects? Sebastian <news@seyweiler.dyndns.org> - 2013-08-07 12:05 +0200
Re: Cost of creating objects? Donkey Hottie <donkey@fredriksson.dy.fi> - 2013-08-07 14:08 +0300
Re: Cost of creating objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-07 08:08 -0400
Re: Cost of creating objects? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-08-07 20:14 -0700
Re: Cost of creating objects? Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-08-08 17:17 -0300
Re: Cost of creating objects? Joerg Meier <joergmmeier@arcor.de> - 2013-08-07 12:37 +0200
Re: Cost of creating objects? Sebastian <news@seyweiler.dyndns.org> - 2013-08-07 19:51 +0200
Re: Cost of creating objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-07 15:51 -0400
Re: Cost of creating objects? Lew <lewbloch@gmail.com> - 2013-08-07 16:52 -0700
Re: Cost of creating objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-07 20:51 -0400
Re: Cost of creating objects? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-08-08 11:24 +0300
Re: Cost of creating objects? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-08-08 10:07 +0100
Re: Cost of creating objects? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-08-08 17:34 +0300
Re: Cost of creating objects? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-08 10:42 -0400
Re: Cost of creating objects? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-08-08 20:45 +0100
Re: Cost of creating objects? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-08 10:38 -0400
Re: Cost of creating objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-08 10:13 -0400
Re: Cost of creating objects? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-07 20:28 -0400
Re: Cost of creating objects? Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-08-08 17:34 -0300
Re: Cost of creating objects? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-08-07 19:19 +0100
Re: Cost of creating objects? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-08-07 19:24 +0100
Re: Cost of creating objects? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-08-07 20:03 -0700
Re: Cost of creating objects? Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-08-08 17:39 -0300
Re: Cost of creating objects? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-07 20:24 -0400
csiph-web