Skip to content

Instantly share code, notes, and snippets.

@nazmul202101
Created December 10, 2016 12:47
Show Gist options
  • Save nazmul202101/0197c5b79106d774169fda0fcda1ed40 to your computer and use it in GitHub Desktop.
Save nazmul202101/0197c5b79106d774169fda0fcda1ed40 to your computer and use it in GitHub Desktop.
Given a string, take the last char and return a new string with the last char added at the front and back, so "cat" yields "tcatt". The original string will be length 1 or more
//Given a string, take the last char and return a new string with the last char added at the front and back, so "cat" yields "tcatt". The original string will be length 1 or more.
//backAround("cat") → "tcatt"
//backAround("Hello") → "oHelloo"
//backAround("a") → "aaa
public String backAround(String str) {
int length = str.length();
char length1 = str.charAt(length-1);
return length1+str+length1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment