-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListEx.java
More file actions
29 lines (25 loc) · 1 KB
/
Copy pathListEx.java
File metadata and controls
29 lines (25 loc) · 1 KB
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
package javaU;
import java.util.ArrayList;
import java.util.List;
public class ListEx {
public static void main(String[] args) {
List<String> words = List.of("Apple", "Bat", "Cat");
System.out.println(words);
System.out.println(words.size());
System.out.println(words.isEmpty());
System.out.println(words.get(0));
System.out.println(words.contains("Dog"));
System.out.println(words.contains("Cat"));
System.out.println(words.indexOf("Cat"));
System.out.println(words.indexOf("Dog"));
List<String> wordsArrayList = new ArrayList<String>(words);
List<String> wordsLinkedList = new ArrayList<String>(words);
List<String> wordsVector = new ArrayList<String>(words);
wordsArrayList.add("Dog");
wordsLinkedList.add("Pig");
wordsVector.add("Cow");
System.out.println(wordsArrayList.toString());
System.out.println(wordsLinkedList.toString());
System.out.println(wordsVector);
}
}