I've worked through it several times, but I can't figure out how CodingBat's solution code correctly returns a two character string.
This is their solution:
public String frontBack(String str) {
if (str.length() <= 1) return str;
String mid = str.substring(1, str.length()-1);
// last + mid + first
return str.charAt(str.length()-1) + mid + str.charAt(0);
}
But why does this work for two character strings? If str = "AB" shouldn't the code return "B" (first part of return) + "B" (in this case wouldn't mid="B") and "A"...so "BBA"? I think I'm missing some logic with how String mid is created with a 2 character string. Thanks!

