I'm trying to use String.valueOf()
to replace the null when i'm calling some method.But it still shows nullpointerexception
. This may be simple but i'm missing something.
I have statement like this
myvar = this.kind.name().toLowerCase()
It is throwing java.lang.NullPointerException
. Im trying to keep string "NULL" whenever i get NPE. so i tried this
myvar = String.valueOf(this.kind.name().toLowerCase()) -- not working
I have found from other posts that it may not work as we have overloaded method String.valueOf(char[])
and String.valueOf(object)
and suggested to use below. But still it s not working. How do i assign string null
in this case?
myvar = String.valueOf((this.kind.name().toLowerCase()) null))