Lists are array-like collections. Unlike arrays, the elements count can be dynamic - there is no need to specify it.
In order to use list, a library needs to be imported:
Defining empty list:
Defining list with elements:
List can contain class objects as elements. Example:
Output:
Explanation:
line 26
a list of classes is defined. line 36
the list is created. It is initialized
with two objects.line 42
an element is added to the list.line 45
the count of elements is printed 49 - 53
list elements are looped.