TopFinding an item in an arrayRemoving or recoloring an element

Removing or recoloring an element

With the above code written it is now easy to remove an element from the array or to recolor it. Just use the private methods above. See the on-line code.

For removing an element we just use the removeAt method of lists.

As an exercise, write code for removing something from the middle of a list and adding something to the middle of a list. (As well as moving items - in the right order - you must also be sure to update the count of the number of items.)

Another nice feature of lists is that you can iterate through them all using a for statement:

   for(shapes) do {nextShape: Graphic2D ->
      print(nextShape)
   }
   

TopFinding an item in an arrayRemoving or recoloring an element