-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDemoList.java
More file actions
34 lines (27 loc) · 1.11 KB
/
Copy pathDemoList.java
File metadata and controls
34 lines (27 loc) · 1.11 KB
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
package KienTrucCollections;
import java.util.ArrayList;
import java.util.List;
public class DemoList {
public static void main(String[] args) {
List<Integer> arrayList = new ArrayList<Integer>();
arrayList.add(10);
arrayList.add(20);
arrayList.add(5);
arrayList.add(2);
arrayList.add(2); //Thêm giá trị tay, sau này thêm bằng code Automation
System.out.println("Các phần tử của ArrayList");
System.out.print("\t" + arrayList + "\n");
for (int number : arrayList) {
System.out.println(number);
}
arrayList.remove(2); //Xoá phần tử vị trí thứ 2
for (int i = 0; i < arrayList.size(); i++) {
//Dùng code automation để gọi dùng trực tiếp từng thằng theo vị trí
System.out.println(arrayList.get(i));
}
// List<String> listTotalStock = new ArrayList<String>();
// listTotalStock.add("");
// List<String> listTotalStock = //code auto để lấy danh sách giá trị gán vào
// listTotalStock.get(2);
}
}