switchPairs

Category: ArrayList
Author: Stuart Reges
Book Chapter: 10.1
Problem: switchPairs
  Write a static method called switchPairs that
   switches the order of values in an ArrayList of Strings in a pairwise
   fashion.  It should switch the order of the first two values, then switch
   the order of the next two, switch the order of the next two, and so on.

   For example, if a variable called list stores these values:

        ["four", "score", "and", "seven", "years", "ago"]

   and we make this call:

        switchPairs(list);

   the method should switch the first pair ("four", "score"), the second pair
   ("and", "seven") and the third pair ("years", "ago"), yielding this list:

	["score", "four", "seven", "and", "ago", "years"]

   If there are an odd number of values in the list, the final element is not
   moved.  For example, if the original list had been:

	["to", "be", "or", "not", "to", "be", "hamlet"]

   It would again switch pairs of values, but the final value ("hamlet") would
   not be moved, yielding this list:

	["be", "to", "not", "or", "be", "to", "hamlet"]