forked from krimanisha/Hacktoberfest21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraylist methods
More file actions
33 lines (23 loc) · 826 Bytes
/
Arraylist methods
File metadata and controls
33 lines (23 loc) · 826 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
import java.util.*;
public class arraylist_methods {
public static void main(String[] args)
{ ArrayList<Integer> l1=new ArrayList<>();
ArrayList<Integer> l=new ArrayList<>();
/// System.out.println(l.size());
l.add(1);
l.add(2);
l.add(3);
l1.add(2);
//Collections.copy(l, l1); //l copy to l1
System.out.println(l);
//Collections.shuffle(l);
//System.out.println(l);
//Collections.reverse(l);
//System.out.println(l);
List<Integer> sublist = l.subList(0,2);
// System.out.println(sublist);
l1.stream().forEach(ele->System.out.println(ele)); //using lambda function
System.out.println("-------------");
Iterator<Integer> it = l1.iterator();
}
}