首页 > 移动平台 > 详细

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

时间:2020-05-14 13:02:17      阅读:80      评论:0      收藏:0      [点我收藏+]

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){
......
}
.......

 

 

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

原文:https://www.cnblogs.com/pzw23/p/12887609.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!