-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListTest.java
More file actions
25 lines (23 loc) · 746 Bytes
/
ListTest.java
File metadata and controls
25 lines (23 loc) · 746 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
package code;
import java.util.ArrayList;
import java.util.List;
public class ListTest {
public static void main(String[] args) {
List<String> books = new ArrayList<>();
books.add(new String("A"));
books.add(new String("B"));
books.add(new String("C"));
books.add(new String("D"));
System.out.println(books);
books.add(1,new String("E"));
for(int i=0;i<books.size();i++){
System.out.println(books.get(i));
}
books.remove(2);
System.out.println(books);
System.out.println(books.indexOf(new String("C")));
books.set(1,new String("F"));
System.out.println(books);
System.out.println(books.subList(1,2));
}
}