Question: static method named swapPairs that accepts an array of strings as a parameter method should switch the Write a and switches the order of values

static method named swapPairs that accepts an array of strings as a parameter method should switch the Write a and switches the order of values in a pairwise fashion. Your 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 the array initially stores these values: Strinell a - ['four", "score", 'and", "seven', 'years "ago": swapPairs(a) Your method should switch the first pair ('four "score"), the second pair ("and" seven") and the third pair ('years", 'ago"), to yield this array: 'score "four. "seven, "and", "ago" "years' If there are an odd number of values, 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
