I have the following arraylist
cd1 = [3,5,7,10,15,16]
cd2 = [4,10,5,8]
The output
[3,7,15,16]
as you can see one has 6 positions and the other 4.
then if they are repeated they should be stored in another ArrayList
Code I carry:
import java.util.ArrayList;
public class inexistentes {
public static ArrayList<Integer> inexistentes(ArrayList<Integer> cd1, ArrayList<Integer> cd2){
ArrayList<Integer> newList = new ArrayList<>();
for(int i = 0; i < cd1.size(); i++){
if(cd1.contains(i) ){
newList.add(i);
}
}
return newList;
}
}
how can i buy those chains...
I already have a for but I don't know how to implement the if.