We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d4f6b3d commit caa9a8bCopy full SHA for caa9a8b
1 file changed
ArrayListDuplicateApp.java
@@ -0,0 +1,29 @@
1
+// https://www.facebook.com/smkmallik/posts/3415890411793806
2
+// Subscribed by Code House
3
+import java.util.ArrayList;
4
+import java.util.LinkedHashSet;
5
+import java.util.List;
6
+import java.util.Set
7
+
8
+class ArrayListDuplicateApp {
9
+ public static void main(String[] args) {
10
+ List<Integer> primes = new ArrayList<Integer>();
11
12
+ primes.add(2);
13
+ primes.add(3);
14
+ primes.add(5);
15
+ primes.add(7);
16
17
+ primes.add(11);
18
19
+ System.out.println("List of Prime Numbers: " + primes);
20
21
+ Set<Integer> primesWithoutDuplicates = new LinkedHashSet<Integer>(primes);
22
23
+ primes.clear();
24
25
+ primes.addAll(primesWithoutDuplicates);
26
27
+ System.out.println("List of primes without duplicates: " + primes);
28
+ }
29
+}
0 commit comments