Re: Java programming style question



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).
.



Relevant Pages

  • Re: View Vs Table of base tables of view
    ... I create a view of x union y union z ... Remove the ns_ from if replying by e-mail (but keep posts in the ... newsgroups if possible). ...
    (comp.databases.sybase)
  • Re: View Vs Table of base tables of view
    ... because creating that table the first time will be ... Remove the ns_ from if replying by e-mail (but keep posts in the ... newsgroups if possible). ...
    (comp.databases.sybase)
  • Re: java network router
    ... Remove the ns_ from if replying by e-mail (but keep posts in the ... newsgroups if possible). ... Does it have to be Java? ...
    (comp.lang.java.softwaretools)
  • Re: Interacting with another application
    ... I have a project in which i have to interact with another application ... Remove the ns_ from if replying by e-mail (but keep posts in the ... newsgroups if possible). ...
    (microsoft.public.vb.general.discussion)
  • Re: recordcount per date ? could you do that?
    ... want to change it to something like "SaleDate" or whatever. ... Remove the ns_ from if replying by e-mail (but keep posts in the ... newsgroups if possible). ...
    (microsoft.public.vb.general.discussion)