【发布时间】:2016-01-11 21:00:37
【问题描述】:
我收到警告,watchStore.contains(s) 是对 java.util.Collection#contains 的可疑调用。我该如何解决?我想使用contains() 来查找具有匹配序列号的特定对象。
public Watch findWatchBySerialNumber(long srch) {
long s = srch;
Watch watch = null;
for(int i = 0; i < watchStore.size(); i++) {
watch = watchStore.get(i);
if(watchStore.contains(s)) {
System.out.print("item found");
return watch;
}
}
System.out.print("item not found");
return null; // watch is not found.
}
【问题讨论】:
-
你可以添加你得到的错误的堆栈跟踪
-
你得到的确切错误是什么?
-
什么是
watchStore? -
watchStore 收藏有哪些内容?看还是看?
-
watchStore来自哪里?