Array Of Class Objects

A class may have a property that is array and contains class instances.

Example

Output:

Explanation:

  • At line 15 an empty array is created.
  • At lines 49 - 51 elements are added to the array.
  • At lines 20 - 29 the array is sorted ascending by price. If at line 21 the sign < is replaced with >, then the sorting would be descending.