forked from codehouseindia/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayListDuplicateApp.java
More file actions
29 lines (22 loc) · 782 Bytes
/
ArrayListDuplicateApp.java
File metadata and controls
29 lines (22 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// https://www.facebook.com/smkmallik/posts/3415890411793806
// Subscribed by Code House
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set
class ArrayListDuplicateApp {
public static void main(String[] args) {
List<Integer> primes = new ArrayList<Integer>();
primes.add(2);
primes.add(3);
primes.add(5);
primes.add(7);
primes.add(7);
primes.add(11);
System.out.println("List of Prime Numbers: " + primes);
Set<Integer> primesWithoutDuplicates = new LinkedHashSet<Integer>(primes);
primes.clear();
primes.addAll(primesWithoutDuplicates);
System.out.println("List of primes without duplicates: " + primes);
}
}