sonar检测常遇报错
场景:在使用sonar检测代码时,检测到工具类中一个报错:Number objects are compared using ‘==’, not ‘equals()’,如下图,其中month 和currentMonth都是Integer类型:
if(month > currentMonth || (month == currentMonth && day > currentDay))
原因:== 是值相等。对于Integer这样的数据类型而言,意义是两个Integer对象的内存
原创
2020-05-14 16:25:41 ·
1078 阅读 ·
0 评论