w22116972
10/18/2019 - 6:47 AM

print two lists

    private void printTwoLists(List<String> list1, List<String> list2) {
        Iterator<String> iterator1 = list1.iterator();
        Iterator<String> iterator2 = list2.iterator();
        while (iterator1.hasNext() && iterator2.hasNext()) {
        System.out.println(
          "iterator1.next() + \",\" + iterator2.next() = "
              + iterator1.next()
              + ","
              + iterator2.next());
        }
        if (iterator1.hasNext()) {
            System.out.println("iterator1.next() = " + iterator1.next());
        }
        else if (iterator2.hasNext()) {
            System.out.println("iterator2.next() = " + iterator2.next());
        }
    }