转换为字符串时,toString() 与 +"" 的区别

xiaoxiao2021-02-28  96

当要将一个对象转换为字符串时,使用object + “” 会比object.toString()要好。因为当遇到oeject为null时,调用toString()方法会报nullpointexception异常,而通过+”“则不会抛出异常

转载请注明原文地址: https://www.6miu.com/read-23849.html

最新回复(0)