Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement