(String) or .toString()?

后端 未结 9 1543
慢半拍i
慢半拍i 2020-12-12 16:56

I have a method with an Object o parameter.

In this method, I exactly know there is a String in \"o\" which is not null. There is no need t

9条回答
  •  死守一世寂寞
    2020-12-12 17:19

    There cannot be a 'null string in o'. If o is null, it does not contain a null string, it is just null. Just check o for null first. If you cast or call ToString() on null you will crash.

提交回复
热议问题