Skip to main content
1 of 2
Gilsham
  • 153
  • 3

You are checking the capital letters twice in your loop, you should increment i by 1 when you add in a space. This will also mean you don't need to use i + 1 to de-capitalise the current letter

str.insert(i, ' '); 
i++;
char ch = Character.toLowerCase(str.charAt(i)); 
str.setCharAt(i, ch);
Gilsham
  • 153
  • 3