java用户提供的数组直接存储
我提到:Security - Array is stored directly
我的代码是
public IndexBlockAdapter(String[] itemStr) {
if(itemStr == null) {
this.itemStr = new String[0];
} else {
this.itemStr = Arrays.copyOf(itemStr, itemStr.length);
}
}
但声纳仍然拿起它,并抱怨“阵列直接存储”,尽管制作了一个副本。我很困惑
感谢您的帮助
# 1 楼答案
它只是复制引用,而不是实际值。 下面的代码将打印所有
true
来证明这一事实相反,如果你使用下面的代码,你会做一个深度复制,你应该做得很好
# 2 楼答案
这应该对你有用