I was checking String.valueOf method and found that when null is passed to valueOf it returns "null" string instead of pure java null.
My question is why someone will return "null" string why not pure java null.
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}
I am asking this because developer will have to check with equals method for "null" string and not like stringObj != null.
[update]: okay there were down votes for this question, I am not raising question in the api but in my current company there are lot of api which returns "null" string instead of pure java null that is why I asked this question to know whether is it a best practice to return "null" string if we found null string object.
null)nullin the first place?nullbut you can print"null"