-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (19 loc) · 723 Bytes
/
Main.java
File metadata and controls
27 lines (19 loc) · 723 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
package com.dj;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
String[] names = {"Anna", "Bob", "Carol", "David", "Edna"};
list.addAll(Arrays.asList(names));
System.out.println(list);
list.add("Fred");
list.addAll(Arrays.asList("George", "Gary", "Grace"));
System.out.println(list);
System.out.println("Gary is in the list? " + list.contains("Gary"));
list.removeIf(s -> s.charAt(0) == 'G');
System.out.println(list);
System.out.println("Gary is in the list? " + list.contains("Gary"));
}
}