Skip to content

Commit be573ec

Browse files
authored
Update CompareListsEx3.java
1 parent ffb15f7 commit be573ec

1 file changed

Lines changed: 1 addition & 37 deletions

File tree

comparesort/CompareListsEx3.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,10 @@
44
import java.util.Comparator;
55
import java.util.List;
66

7-
// Compare lists by sorting and transfering to strings
8-
// We assume that in-place sorting is OK
9-
10-
public class CompareListsEx2 {
11-
12-
public static boolean compareList(List<String> l1, List<String> l2) {
13-
14-
return l1.toString().contentEquals(l2.toString());
15-
}
7+
public class CompareListsEx3 {
168

179
public static void main(String[] args) {
1810

19-
List<String> words = new ArrayList<>();
20-
List<String> words2 = new ArrayList<>();
21-
22-
words.add("dog");
23-
words.add("pen");
24-
words.add("sky");
25-
words.add("rock");
26-
27-
words2.add("dog");
28-
words2.add("pen");
29-
words2.add("rock");
30-
words2.add("sky");
31-
32-
words.sort(Comparator.naturalOrder());
33-
words2.sort(Comparator.naturalOrder());
34-
35-
System.out.println(words);
36-
System.out.println(words2);
37-
38-
boolean equal = compareList(words, words2);
39-
40-
if (equal) {
41-
42-
System.out.println("Lists are equal");
43-
} else {
44-
45-
System.out.println("Lists are not equal");
46-
}
4711

4812
}
4913
}

0 commit comments

Comments
 (0)