I've been trying to write this code for a while now and I cannot figure out what is wrong with my nested for loop. I think it may be a problem with my if statement but I'm not sure. The code is supposed to search through ten random playing cards to find any duplicates. I know the rest of the code is working but I cannot figure out what I've done wrong with this part. If anyone could help I would be really grateful. (Java)
/*
* Return true if there is a duplicate card in the pack
*/
public boolean hasDuplicate() {
for (int i = 0; i < pack.size(); i++){
for (int j = i; j < pack.size(); j++) {
if (i != j && pack.get(i).equals(pack.get(j))){
pos = i;
return true;
}
}
}
return false;
}
pack?.equals()on whatever's in the list?Card