-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava08_8_1CollectionsTest.java
More file actions
37 lines (28 loc) · 1010 Bytes
/
java08_8_1CollectionsTest.java
File metadata and controls
37 lines (28 loc) · 1010 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
37
import java.util.*;
import java.io.*;
class java08_8_1CollectionsTest{
public static void main(String[] args) throws java.lang.Exception{
//
ArrayList al = new ArrayList();
al.add(10);
al.add(20);
al.add(-10);
al.add(5);
System.out.println(al);
//Collections 操作一些排序、旋转、交换等操作;
Collections.reverse(al);
System.out.println(al);
Collections.rotate(al,2);
System.out.println(al);
Collections.sort(al);
System.out.println(al);
Collections.shuffle(al);
System.out.println(al);
List saftAl = Collections.synchronizedList(al);
//不可变类创建方法
System.out.println("===== UnmodifiableLink =====");
List unmodifiableLink = Collections.unmodifiableList(al);
//unmodifiableLink.add(5);
System.out.println(unmodifiableLink);
}
}