gpt4 book ai didi

java - 为什么 FindBugs 在这里提示?

转载 作者:行者123 更新时间:2023-11-29 05:57:02 24 4
gpt4 key购买 nike

 public int getFreezeColumns() {
Integer currentValue = (Integer) checkValueBinding("freezeColumns", this.freezeColumns);
if (currentValue != null) {
return currentValue;
}
return 0;
}

FindBugs 说:

A primitive is boxed, and then immediately unboxed. This probably is due to a manual boxing in a place where an unboxed value is required, thus forcing the compiler to immediately undo the work of the boxing.

我该如何解决这个问题?

最佳答案

我认为投诉有些误导:您没有装箱 checkValueBinding 的返回值,它是一个 Object,而是将其转换为 Integer 过早地

尝试更改代码以查看它是否可以帮助您避免警告:

public int getFreezeColumns() {
Object currentValue = checkValueBinding("freezeColumns", this.freezeColumns);
if (currentValue != null) {
return (Integer)currentValue;
}
return 0;
}

关于java - 为什么 FindBugs 在这里提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11673744/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com