Java findbugs: suspicious comparison of long references

Findbugs identified the following error in my code: @ h_ 404_ 7@

if (materialDeFinition.getId() == deFinitionToRemoveFromClass.getId()) {
    //...
}

Solution

final Long id1 = materialDeFinition.getId();
final Long id2 = deFinitionToRemoveFromClass.getId();

if (id1.equals(id2)) {
    //...
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>