beyondgrader.com Logo
DemoBrowseAboutTeamLogin

String Flip Halves

Geoffrey Challen // 2021.8.0

Write a method name flipHalves that returns a passed String rearranged as follows. You should move the second half of the string to the front, and the first half to the back. So given the String "CS" you would return "SC", and given the String "testme" you would return "tmetes". However, if the length of the String is odd the middle character should remain in place. So given the String "CS124" you would return "241CS". If the passed String is empty, just return the empty String.

You will definitely want to review the substring String method, and also spend some time experimenting with it before you begin crafting your solution. You also may want to consider odd and even length Strings separately.