IDEA代码里的黄色提示

#cec726

提示:String concatenation as argument to 'StringBuilder.append()' 

详细提示

String concatenation as argument to 'StringBuilder.append()' call less... (Ctrl+F1)
Inspection info: Reports String concatenation used as the argument to StringBuffer.append(), StringBuilder.append() or Appendable.append(). Such calls may profitably be turned into chained append calls on the existing StringBuffer/Builder/Appendable, saving the cost of an extra StringBuffer/Builder allocation.
This inspection ignores compile time evaluated String concatenations, which when converted to chained append calls would only worsen performance.

解释

append方法就是为了解决String += String的效率问题的,而上面代码在append方法里使用了字符串连接,可能降低性能。解决提示:不要在append方法里写字符串连接代码。

C-style array declaration of local variable 'arr' less... 

详细提示

C-style array declaration of local variable 'arr' less... (Ctrl+F1)
Inspection info: Reports array declarations made using C-style syntax, with the array indicator brackets positioned after the variable name or after the method parameter list. For example:
public String process(String value[])[] {
return value;
}
Most code styles prefer Java-style array declarations, with the array indicator brackets attached to the type name.

解释

数组对象,把中括号放在变量后面是C语言的风格,而Java习惯放在变量类型后面

'for' loop replaceable with 'foreach' less... 

详细提示

'for' loop replaceable with 'foreach' less... (Ctrl+F1)
Inspection info: Reports for loops which iterate over collections or arrays, and can be replaced with the foreach iteration syntax, available in Java 5 and newer.

解释

循环遍历集合或数组,可以替换为foreach迭代语法

Local variable 's' is redundant less...

详细提示

Local variable 's' is redundant less... (Ctrl+F1)
Inspection info: Reports unnecessary local variables, which add nothing to the comprehensibility of a method. Variables caught include local variables which are immediately returned, local variables that are immediately assigned to another variable and then not used, and local variables which always have the same value as another local variable or parameter.

解释

定义的变量名称是冗余的

Field injection is not recommended less...

详细提示

Field injection is not recommended less... (Ctrl+F1)
Inspection info: Spring Team recommends: "Always use constructor based dependency injection in your beans. Always use assertions for mandatory dependencies".

解释

Spring团队建议:“始终在bean中使用基于构造函数的依赖注入

Found duplicate code

鼠标放在重复代码块,Alt+Enter

查看其它重复代码,可以做比较

原文地址:https://www.cnblogs.com/LUA123/p/13267466.html