Created
December 10, 2016 12:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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