-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEX-04-List.dart
41 lines (31 loc) · 847 Bytes
/
EX-04-List.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
/*
Types of List –
There are broadly two types of list on the basis of its length:
1.Fixed Length List
2.Growable List
// Declaring list
var list_name = new List (size);
// Inserting elements in list
list_name[index] = value;
//////Inserting Element into List
Dart provides four methods which are used to insert the elements into the lists. These methods are given below.
add()
addAll()
insert()
insertAll()
*/
void main() {
var num_list = [1, 2, 3, 4];
print(num_list);
/////////////// add() Function ////////////////////////
var odd_list = [1, 3, 5, 7];
print(odd_list);
odd_list.add(9);
print(odd_list);
/////////////// addAll() Function ////////////////////////
odd_list.addAll([11, 13, 15]);
print(odd_list);
///////////// insert() ////////////////////////////////
odd_list.insert(3, 17);
print(odd_list);
}