Collection Of Classes

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 of class objects:

List can contain class objects as elements. Example:



  • At line 26 a list of classes is defined.
  • At line 36 the list is created. It is initialized with two objects.
  • At line 42 an element is added to the list.
  • At line 45 the count of elements is printed
  • at lines 49 - 53 list elements are looped.