Richard...

Richard Clark wrote:
> Look at my code again...
>
>   if (null == s || s.length() == 0) ...
>
> Java translates x == y into x.equals(y). If I had said
>   if (s == null)
> and s was null, you would get a null pointer exception.

What? Which version of Java "translates x == y into x.equals(y)"? I have
never heard of this, and it troubles me greatly as I've written code
that relies on the differences between == and equals().

More on topic: I tend to us the following:

  if ( "someValue".equals( s ) ) {}

Unless I need to check specifically for a null value, in which case I
use:

  if ( s != null && s.length() > 0 ) {}

- Paul Philion

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to