i got two String type arraylist ..one list containing “book1”, “book2”, “book3” and “book4”. And another arrayList contains “book1”, “book2”, “book3”. So, size of first list is 4 and second is 3. And I created another arrayList equal to the size of first list
List<Integer> comparingList = new ArrayList<Integer>();
//adding default values as one
for(int a=0;a<firstList.size();a++){
comparingList.add(0);
}
And if any content is equal between two lists, I’m setting 1 instead of 0.
so the new arrayList(comparingList) should have 1,1,1,0 elements
for(int counter = 0;counter < firstList.size();counter++){
for(int counter1 = 0;counter1 < secondList.size();counter1++){
if(firstList.get(counter).equals(secondList.get(counter1))){
comparingList.set(counter,1);
break;
}
}
}
but when i do this, i’m not being able to set 1 as I can’t get into if condition, can anyone help me please
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…