Question: (Intro to java help?) ArrayList Write a static method called flip2 that takes an ArrayList of Strings as a parameter and then flips each successive
(Intro to java help?)
ArrayList
Write a static method called flip2 that takes an ArrayList of Strings as a parameter and then flips each successive pair of values in the list. For example, suppose that a variable called list stores the following sequence of values:
["aa", "bb", "cc", "DDD", "happy", "snow"]
and we make the following call:
flip(list);
Afterwards the list should store the following sequence of values:
["bb", "aa", "DDD", "cc", "snow", "happy"]
If the list has extra values that are not part of a pair, those values are unchanged. For example, if the list had instead stored:
["aa", "bb", "cc", "DDD", "happy", "snow", "hometown"]
The result would have been:
["bb", "aa", "DDD", "cc", "snow", "happy", "hometown"]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
