Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. //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.
  2.  
  3. //backAround("cat") → "tcatt"
  4. //backAround("Hello") → "oHelloo"
  5. //backAround("a") → "aaa
  6.  
  7. public String backAround(String str) {
  8. int length = str.length();
  9.  
  10. char length1 = str.charAt(length-1);
  11.  
  12. return length1+str+length1;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement