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

 

crehwinkel@frhsd.com apcsa-exam-review-strings1 > switchFirstTwoLastTwo
prev  |  next  |  chance

Write a method called switchFirstTwoLastTwo that takes a String as it's parameter and returns a new String with the first two and last two characters switched. For example a call of switchFirstTwoLastTwo("hello") would return the String "lolhe".

However, if the String passed into the method is shorter than or equal to 4 characters or if the String starts with "ne" or if it ends with "s", just return what was passed into the method without switching any characters.


switchFirstTwoLastTwo("good bye") → "yeod bgo"
switchFirstTwoLastTwo("") → ""
switchFirstTwoLastTwo("fish") → "fish"

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

public String switchFirstTwoLastTwo(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: 100

Copyright Nick Parlante 2017 - privacy