You are on page 1of 7

CHECKLIST

Lecture Checklist

Code 25e-BM/HR/HDCV/FSOFT
Version 1.0
Effective Date 1-Jul-2019
678174952.xlsx v1.7
Lecture Checklist
Project Code: "YES"
Reviewer(s): "NO"
Version of the work product: "N/A"
Review date:
Work product' size:
Effort spent on audit (person-hour):
#REF!
No Checked Items Assessment
List Collection

1 Hiểu về interface List và các lớp con của List?

2 So sánh sự giống và khác nhau giữa ArrayList, Vector, LinkedList?

3 So sánh sự khác nhau giữa Array (mảng tĩnh) và ArrayList?

4 Có mấy cách để duyệt một ArrayList trong Java?

5 Hiểu về Iterator? Thực hành sử dụng Iterator?

02e-CL/DE/HDCV/FSOFT Internal use 2/7


678174952.xlsx v1.7

6 Làm thế nào đề convert một Array về Arraylist trong Java?

* Comments

* Suggestion
[ ] - Pass
[ ] - Review again

02e-CL/DE/HDCV/FSOFT Internal use 3/7


678174952.xlsx v1.7

0
0
0

Notes Priority

- List là một interface trong bộ Collection, cho phép lưu trữ các giá trị trùng lặp.
- List có 3 lớp con thực hiện implements trực tiếp là : ArrayList, Vector, LinkedList. Mandatory

Điểm giống nhau: đều implements trực tiếp từ List


Điểm khác nhau:
- ArrayList: được thiết kế như một mảng động, có thể thay đổi kích thước. Truy xuất phần tử nhanh thông qua index.
- LinkedList: được thiết kế như một double linked list. Có hiệu xuất cao trong việc thêm và xóa các phần tử so với
ArrayList nhưng truy xuất chậm do phải duyệt các node để tìm. Mandatory
- Vector: giống với ArrayList, nhưng thread-safe (các phương thức synchronized) => tiêu tốn tài nguyên nhiều hơn so
với ArrayList do quá trình đồng bộ nhưng an toàn trong các ứng dụng đa luồng.

- Array:
+ Là một mảng tĩnh (không thể thay đổi size một khi đã thực hiện khởi tạo).
+ Có thể lưu trữ được cả dữ liệu nguyên thủy (primitive) và dữ liệu dạng đối tượng (object).
+ Cho phép tạo mảng đa chiều.
- ArrayList: Mandatory
+ Là một mảng động (size có thể thay đổi theo số lượng phần tử).
+ Chỉ lưu trữ được các dữ liệu kiểu đối tượng (object).
+ Chỉ có thể 1 khởi tạo chiều.

- Sử dụng for loop:


VD: List<Integer> list = new ArrayList<Integer>();
int size = list.size();
for(in i=0; i<size; i++){
System.out.println(list.get(i));
}

- Sử dụng for-each loop.


VD: List<Integer> list = new ArrayList<Integer>();
for(Integer element : list){
System.out.println(element);
}

- Sử dụng Interator: //Có thể vừa duyệt vừa xóa element trong list. Mandatory
VD: List<Integer> list = new ArrayList<Integer>();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
System.out.print(iterator.next());
}

- Sử dụng forEach() trong Java 8.


VD: List<Integer> list = new ArrayList<Integer>();
list.stream().forEach(element -> { System.out.println(element); });

- Iterator là một interface thuộc gói java.util dùng đề duyệt các phần tử theo một chiều và cho phép có thể vừa duyệt
vừa xóa.
- Iterator có thể được sử dụng trong List, Set và Queue.
- Iterator cung cấp 3 methods:
+ hasNext() : boolean - trả về true nếu còn phần tử và ngược lại.
+ next() : E - lấy phần tử tiếp theo
+ remove() : void - xóa đi phần tử đang được next() tới.
VD:
List<String> animals = new ArrayList<String>();
animals.add("fox");
animals.add("cat");
animals.add("dog");
animals.add("rabbit");

Iterator<String> iterator = animals.iterator();


while(iterator.hasNext()){
String value = iterator.next();
if( value.equals("cat")){
iterator.remove();
}
}
=> animals = [fox, dog, rabbit]

02e-CL/DE/HDCV/FSOFT Internal use 4/7


678174952.xlsx v1.7
- Sử dụng phương thức static asList() đươc cung cấp bởi class Arrays. [Arrays.asList(T[] t) : List<T>]
VD:

String cityArray[] = {"Delhi", "Mumbai", "Bangalore", "Hyderabad", "Chennai"};


List<String> cityList = Arrays.asList(cityArray);

// cityList = ["Delhi", "Mumbai","Bangalore","Hyderabad"," Chennai"]


Mandatory
=> Khi đo List mới thu được sẽ không thể remove hoặc add các element, chỉ có thể update các element trước đó.
cityList.add("HaNoi"); // throw exception UnsupportedOperationException
cityList.remove("Delhi"); // throw exception UnsupportedOperationException
cityList.set(1, "HaNoi"); // OK, cityList = [Delhi, HaNoi, Bangalore, Hyderabad, Chennai]

02e-CL/DE/HDCV/FSOFT Internal use 5/7


678174952.xlsx v1.7

RECORD OF CHANGE
No Effective Date Version Change Description Reason Reviewer
1 N/A 1.0 Newly issue Apply for Lab/Assignment DienNT1
2 1-Jul-19 1.0 Update Update for Release DuongTQ
3
4
5
6
7
8

02e-CL/DE/HDCV/FSOFT Internal use 6/7


678174952.xlsx v1.7

Approver
VinhNV
VinhNV

02e-CL/DE/HDCV/FSOFT Internal use 7/7

You might also like