Java Array, Finding Duplicates

前端 未结 14 914
闹比i
闹比i 2020-11-22 09:13

I have an array, and am looking for duplicates.

duplicates = false;
for(j = 0; j < zipcodeList.length; j++){
    for(k = 0; k < zipcodeList.length; k++         


        
14条回答
  •  一生所求
    2020-11-22 10:02

    How about using this method?

    HashSet zipcodeSet = new HashSet(Arrays.asList(zipcodeList));
    duplicates = zipcodeSet.size()!=zipcodeList.length;
    

提交回复
热议问题