-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Phil Swenson
>class StringUtil{
> public static String blankNull(String s){
> if (s==null)
> return new String("");
> else
> return s;
> }
>}
>
>I've always been a bit confused about a call to return ""...it should
return a an empty string, but I kept >encountering nulls, so now I always
use return new String("") instead.
No, you should be fine doing a simple return( "" );
I sometimes use the tenary operator as follows:
this.name = name == null ? "" : name;
as an inline equivalent of what your method does. In fact this is only one
of the few cases where I use the tenary operator.
It's debateable which is better/more readable/etc...
Steve S
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html