Reports local variable of wrapper type though all usages allowed to be primitive and count of unnecessary boxing/unboxing operations reduces

报告包装器类型的局部变量,尽管所有使用情况都允许是原始用法,并且不必要的装箱/拆箱操作的次数减少了

 

这个警告是说,尽量使用基本数据类型,这样就能减少装箱/拆箱操作了。

类似的例子:

......

Boolean hs=false;
for(var it:collect){
    if(it.getYear==2020){
       hs=true;
       .....
    }   
}
if(!hs){
......
}
.......

改成基本数据类型就行了,比如int

......

int hs=0;
for(var it:collect){
    if(it.getYear==2020){
       hs=1;
       .....
    }   
}
if(hs==0){
......
}
.......