[edited this question at 2020/07/27 01:30 UTC]
What do you thínk about Java designers decided java.lang.String.valueOf((Object)null)
returns "null"
but not ""
which is the length 0 text ?
I think that ""
text is better than "null"
text instead of null
text.
I have already understood that null
and ""
are different,
but sometimes ""
and null
means empty value on programs.
Actually, org.apache.commons.lang3.StringUtils.isEmpty()
that returns true if value is ""
or null
.
If String.valueOf(null)
returns ""
, String.valueOf(null).isEmpty()
returns true
.
To avoid NullPointerException, we sometime use []
array instead of null array. new String((char)[])
returns ""
.
I think that a meaning of "zero" is "nothing", so length of null
should be 0.