変数を渡すメソッドを呼び出しています。ArrayList
この変数をのすべてのアイテムと比較して、一致するものがあるかどうかを確認できるようにしたいと思います。
これは私のコードです...
private boolean input;
private ArrayList chcekItem = new ArrayList();
public void setAction(String action) {
input=true;
if (getChcekItem().isEmpty()) {
getChcekItem().add(action);
}
else {
Iterator iterators = getChcekItem().iterator();
while (iterators.hasNext()) {
if (iterators.next()==action) {
System.out.println(iterators.next()+"="+action);
input=false;
}
}
if (input) {
getChcekItem().add(action);
System.out.println("The item " + action + " is Successfully Added to array");
}
else{
System.out.println("The item " + action + " is Exist");
}
}
}
コードが期待どおりに機能していません。誰かが私が問題を解決するのを手伝ってくれませんか。