StringBuilder使用append提示String concatenation as argument to 'StringBuilder.append()' call

StringBuilder使用append提示

String concatenation as argument to 'StringBuffer.append()' call 
less... (Ctrl+F1)

Reports String concatenation used as the argument to StringBuffer.append(),StringBuilder.append() orAppendable.append(). Such calls may profitably be turned into chained append calls on the existingStringBuffer/Builder/Appendable,
saving the cost of an extraStringBuffer/Builder allocation.

This inspection ignores compile time evaluated String concatenations, which when converted to chained append calls would only worsen performance.     

这里写图片描述

其实这个提示是表示方法使用不恰当,因为StringBuffer对象的append方法目的就是做对象拼接用的,里面再通过“+”来拼接就不得当,这是编译器对Java的代码规范。

不过实际操作过程中,如果涉及这类“+”拼接与append混合使用时,处理数据量多的话,还是忽略掉这个提示。

你可能感兴趣的:(JAVA)