Skip to content

Commit

Permalink
Growable List
Browse files Browse the repository at this point in the history
  • Loading branch information
smartherd committed Sep 2, 2018
1 parent 707ab66 commit c4b4555
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions 32_list_growable.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,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]);
}

}

0 comments on commit c4b4555

Please sign in to comment.