String.valueOf() vs. Object.toString()

后端 未结 10 770
挽巷
挽巷 2020-12-12 10:21

In Java, is there any difference between String.valueOf(Object) and Object.toString()? Is there a specific code convention for these?

10条回答
  •  不知归路
    2020-12-12 10:46

    When argument is null, the String.valueOf returns "null", but Object.toString throws NullPointerException, that's the only difference.

提交回复
热议问题