tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Einfeldt <ralph.einfe...@uptime-isc.de>
Subject AW: Using Tomcat with MSAccess
Date Thu, 09 Aug 2001 08:28:04 GMT
See remarks below.

> -----Urspr√ľngliche Nachricht-----
> Von: John Baker [mailto:jbaker@teamenergy.com]
> Gesendet: Donnerstag, 9. August 2001 09:55
> An: tomcat-user@jakarta.apache.org
> Betreff: Re: Using Tomcat with MSAccess
<snip />
> > 	"".equals(passwd)
> > rather than
> > 	passwd.equals( "" )
<snip />
> No you shouldn't. That's totally evil. For a start, you're 
> creating another String object by doing ""
<snip/>
<remark>
  As "" is a constant string, it is created just once. So there
  is not much overhead. ("".equals might be even faster, because 
  the jit can inline the method call, as the address of the object 
  and the equals method is constant in this case.
</remark>
> and to add to this, you're saying it's ok to pass null to 
> equals. Passing null to the equals method is an awful idea. 
<remark>
  Why ? "".equals(null) returns false, that what you wan't 
  in most cases. (That return value is not implementation 
  specific, it's granted by the API.)

</remark>
> You actually want:
> 
> if ((passwd != null) && (passwd.lenght() == 0)) {
>    // Then do something
> }
<snip/>
<remark>
  That's wrong, to be equivalent to ("".equals(passwd)) 
  it should be:

  if ((passwd == null) || (passwd.lenght() == 0)) {
     // Then do something
  }
</remark>

Mime
View raw message