Compare every item to every other item in ArrayList

后端 未结 5 883
孤街浪徒
孤街浪徒 2021-02-05 08:07

I\'m having trouble with what I thought should be a pretty simple problem.

I need to compare every item in an arrayList with every other item in the the list without com

5条回答
  •  情话喂你
    2021-02-05 08:15

    In some cases this is the best way because your code may have change something and j=i+1 won't check that.

    for (int i = 0; i < list.size(); i++){  
        for (int j = 0; j < list.size(); j++) {
                    if(i == j) {
                   //to do code here
                        continue;
                    }
    
    }
    

    }

提交回复
热议问题