-
Notifications
You must be signed in to change notification settings - Fork 387
/
32_list_growable.dart
46 lines (31 loc) · 982 Bytes
/
32_list_growable.dart
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
// Objectives
// 1. Growable list
void main() {
// Elements: N 21 12
// Index: 0 1 2
List<String> countries = ["USA", "INDIA", "CHINA"]; // Growable List : METHOD 1
countries.add("Nepal");
countries.add("Japan");
List<int> numbersList = List(); // Growable List: METHOD 2
numbersList.add(73); // Insert Operation
numbersList.add(64);
numbersList.add(21);
numbersList.add(12);
numbersList[0] = 99; // Update operation
numbersList[1] = null; // Delete operation
print(numbersList[0]);
numbersList.remove(99);
numbersList.add(24);
numbersList.removeAt(3);
// numbersList.clear();
print("\n");
for (int element in numbersList) { // Using Individual Element ( Objects )
print(element);
}
print("\n");
numbersList.forEach((element) => print(element)); // Using Lambda
print("\n");
for (int i = 0; i < numbersList.length; i++) { // Using Index
print(numbersList[i]);
}
}