Compare every item to every other item in ArrayList

后端 未结 5 879
孤街浪徒
孤街浪徒 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:19

    The following code will compare each item with other list of items using contains() method.Length of for loop must be bigger size() of bigger list then only it will compare all the values of both list.

    List str = new ArrayList();
    str.add("first");
    str.add("second");
    str.add("third");
    List str1 = new ArrayList();
    str1.add("first");
    str1.add("second");
    str1.add("third1");
    for (int i = 0; i

    Output is true true false

提交回复
热议问题