Re: Java programming style question
- From: David Kerber <ns_dkerber@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 4 May 2007 22:08:13 -0400
In article <1178294413.418046.7710@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
mike.mkaufman@xxxxxxxxxxxxxx says...
On May 4, 3:00 pm, David Kerber
<ns_dkerber@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
What is the preferred way of checking for an empty string that I already
know is not Null?
Is it better (however you define that) to check for .length = 0, or
.equals( "" )?
TIA!
Dave
--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
As of JDK 6, the String class now has an "isEmpty" method that returns
true if the length is zero. So I'd say use "isEmpty" if on JDK 6, or
otherwise check the length.
Yes, I'm using 1.5, so that's what I'll use. Thanks for the comments,
guys!
--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
.
- References:
- Java programming style question
- From: David Kerber
- Re: Java programming style question
- From: Mike
- Java programming style question
- Prev by Date: Re: Java programming style question
- Next by Date: announcing SemmleCode and .QL
- Previous by thread: Re: Java programming style question
- Next by thread: announcing SemmleCode and .QL
- Index(es):
Relevant Pages
|
|