[jdom-interest] getText() returns null or ""

Ryan Leavengood ryan at wctravel.com
Tue Oct 3 12:35:36 PDT 2000


+1 on returning "".  My thoughts are that nulls should only be returned to
indicate an error condition or flag something.  In this case I think ""
makes a lot more sense and of course helps us avoid those pesky
NullPointerExceptions :)

= R y a n =


> Folks-
>
> What's the deal with getText() returning null when it has no value?
> That's what the docs say, and I guess that one just slipped by me (I've
> been really busy lately ;-) ). In any case, that doesn't seem right -
> wouldn't it be better to return ""? Is there any functional difference
> between "" and null? It seems that returning null could cause
> NullPointerExceptions, while "" always insures you can compare Strings.
>
> Thoughts? I'd like to suggest changing to returning the empty String
> when there's no value.
>
> Thanks,
> Brett




More information about the jdom-interest mailing list