id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

frew@mclean.com unit7day4 > switchPairs
prev  |  next  |  chance

Write a method named switchPairs that accepts an array of strings as a parameter and switches the order of pairs of values in the array. Your method should swap the order of the first two values, then switch the order of the next two, and so on. If there are an odd number of values, the final element is not moved.


switchPairs(["a", "bb", "c", "ddd", "ee", "f", "g"]) → ["bb", "a", "ddd", "c", "f", "ee", "g"]
switchPairs(["I", "have", "a", "dream"]) → ["have", "I", "dream", "a"]
switchPairs([]) → []

...Save, Compile, Run (ctrl-enter)

public String[] switchPairs(String[] words) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy