As the title says.
In want to remove the last letter of every word in an array and put it to the beginning of every word.
Here's an example (Input):
Hello I am a player
And here's the output:
oHell I ma a rplaye
I tried:
StringBuffer lastChar = new StringBuffer(output);
lastChar.deleteCharAt(lastChar.length()-1);
System.out.println(lastChar);
But it will just remove the last char of the String and won't put it to the beginning. AND does it only for a whole sentence and not for every word individually.
Love your help here!
First, we must parse the string into its words. We can do this with
After we have an array of words, we just have to loop through it and modify each element.
Finally, we have to recombine the array into a single string.