|
I personally don't allow nulls for most things...I
have a little utility method that blanks nulls (StringUtil.blankNull(String s))
that I call in all my "set" methods in my Java classes. Using this method
you will just be printing empty strings and won't see any "null" in your
presentation.
Example in a "Person" class
class Person{
private String
name;
public setName(String
name){
this.name =
StringUtil.blankNull(name);
}
}
part of my utility class:
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.
I'd love to hear any critique of this method (I'm
still new to Java)...
|
- null in HTML fields plus other stuff Bill White
- Re: null in HTML fields plus other stuff Phil Swenson
- Re: null in HTML fields plus other stuff Stephen Summerfield
- Re: null in HTML fields plus other stuff Hans Bergsten
- Re: null in HTML fields plus other stuff Duffey Kevin
- Re: null in HTML fields plus other stuff Drew Cox
- Re: null in HTML fields plus other stuff Duffey Kevin
