-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.java
More file actions
33 lines (21 loc) · 708 Bytes
/
Copy pathLists.java
File metadata and controls
33 lines (21 loc) · 708 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
30
31
32
33
package io.codelex.notes.day08;
import java.util.ArrayList;
import java.util.List;
public class Lists {
public static void main(String[] args) {
List<String> listOfNames = new ArrayList<>();
System.out.println("=== ADDING ELEMENTS ===");
listOfNames.add("Miks");
listOfNames.add("Zanda");
listOfNames.add("Alise");
for (String name : listOfNames) {
System.out.println(name);
}
System.out.println("=== REMOVING ELEMENTS ===");
listOfNames.remove("Zanda"); // by value
listOfNames.remove(0); // by index
for (String name : listOfNames) {
System.out.println(name);
}
}
}