-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo2.java
More file actions
36 lines (30 loc) · 766 Bytes
/
Demo2.java
File metadata and controls
36 lines (30 loc) · 766 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
34
35
36
package Collections;
import java.util.ArrayList;
import java.util.Collections;
public class Demo2 {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>(1000);
list.add("Hello");
list.add(0, "Bye");
list.remove(0);
int index = list.indexOf("Hi");
String prevValue = list.get(index);
list.set(index, "Hello...");
Collections.sort(list);
if (list.contains("Hi")) {
System.out.println("Found...");
} else {
System.out.println("Not Found...");
}
System.out.println(list.size());
list.trimToSize();
// list.clear();
// list.add(100);
// list.add(true);
// 1.4
// list.add(new Integer(10));
// list.add(new Boolean(true));
String val = (String) list.get(0);
System.out.println(val);
}
}