I have a code that I made to invert a String, but it does not match what I need. I need it to convert the order of the characters of each sentence.
For example: It converts "Hi everyone!" in "real life". And what I need is for him to turn into "iO!".
My code:
public class ex1 {
public static void main(String[] args) {
String palavra = "Abobora Vermelha";
String resultado="";
for(int x = palavra.length() -1;x>=0;x--){
resultado = resultado + palavra.charAt(x);
}
System.out.println(resultado);
}
}