PDE - Reading Values (Lesson)

Reading Values

Reading Values in an Array

In order to swap or exchange values in an array, you must be cognizant of several items. 

  • the length of the array
  • the array index that will be swapped
  • when to end the loop

This time we are using a String array.  A string is characters and symbols allowed for general use in a programming language.  In this case the letters a, b, c, d were used.  Words could have been used as well or phrases.  

In this code notice that the Orca Whale says the testString in various ways:

  • the order the array was created in from left to right as we read.
  • the reverse order without changing the order in the array, from right to left.

ReadingValues1.jpg

Demonstration Video

View the video below of Basic Code above reading the array as entered forward and backwards.

Did the orca swap the array?  No, the orca simply read the array from back to front.  If you did not look at the code you would not know. If someone really wanted the order reversed in the array permanently, and went to use the array in the new reversed order, they would discover that the array is not reversed.

IMAGES AND VIDEO CREATED BY GAVS.