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

 

jebbert@volusia.k12.fl.us > dec9_2016_APSLHL_swapPairs
prev  |  next  |  chance

Write a method that returns a string where all the pairs of characters have had their positions swapped, starting at the beginning of the string. If the string has an odd number of characters the last character will not get swapped with anything but will still be in the new string. The only string methods you are allowed to use are .length, .substring, .charAt, and .equals.


dec9_2016_APSLHL_swapPairs("") → ""
dec9_2016_APSLHL_swapPairs("x") → "x"
dec9_2016_APSLHL_swapPairs("xy") → "yx"

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

public String dec9_2016_APSLHL_swapPairs(String str) { }

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

Difficulty: 240

Copyright Nick Parlante 2017 - privacy