Difference String.valueOf (Object obj) and toString () of

Original link: https://blog.csdn.net/qq_39208491/article/details/82992513

1. Object both the String object into type.

2.String.valueOf () method is non-empty do judge, also inside the call toString () method

  1. public static String valueOf(Object obj) {

    1. return (obj == null) ? "null" : obj.toString();

    2. }

3. toString () is not judged as a non-null, null packets may use the pointer type conversion abnormality or abnormal

4. Personal opinion: String.valueOf () better use some.

 

Guess you like

Origin blog.csdn.net/qq_41557799/article/details/102779792