Skip to content

Instantly share code, notes, and snippets.

@pambrose
Created April 14, 2020 02:20
Show Gist options
  • Save pambrose/9d200e86402578acc787b3efcd07c43a to your computer and use it in GitHub Desktop.
Save pambrose/9d200e86402578acc787b3efcd07c43a to your computer and use it in GitHub Desktop.
public String frontBack(String str) {
if (str.length() < 2)
return str;
String b = str.substring(0, 1);
String e = str.substring(str.length() - 1, str.length());
String m = str.substring(1, str.length() - 1);
return e + m + b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment