-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLearnArrayList.java
54 lines (36 loc) · 1.15 KB
/
LearnArrayList.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class LearnArrayList{
public static void main(String args[]){
List<String> list = new ArrayList();
list.add("Shivani");
list.add("Nikita");
list.add("Prem");
// System.out.println(list);
//list.add("Punam");
//System.out.println(list);
//list.add(4,"Sangale");
//System.out.println(list);
//List<String> newlist = new ArrayList();
//newlist.add("abc");
//newlist.add("xyz");
// list.addAll(newlist);
// System.out.println(newlist);
// System.out.println(list);
//System.out.println(list.get(2));
// list.remove(0);
//System.out.println(list);
list.remove(String.valueOf("Shivani"));
System.out.println(list);
// list.clear();
//System.out.println(list);
// list.set(1,"mno");
//System.out.println(list);
System.out.println(list.contains("Nikita"));
Iterator<String>it=list.iterator();
while(it.hasNext()){
System.out.println("iterator " +it.next());
}
}
}