Hello! I'm kinda new to programming so here's my problem. How can I reverse a String and then at the same time make the last letter deleted using a loop until all what's left is a single letter. For example: User inputs "programming" The code should loop the input deleting one letter at a time (while reversed) What should be the output is something like this: gnimmargorp gnimmargor gnimmargo gnimmarg gnimmar gnimma gnimm gnim gni gn g How can I make it done like that? Please help thanks alot!
What I have tried so far is this:
public static void reverseString() { for (int i = phrase.length() - 1; i >= 0; i--) { reverse += phrase.charAt(i); } System.out.println(reverse); }
This will only reverse the String but not delete one letter at a time. I'm stuck here and can't think of a possible way to do it. Please help thanks alot!
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)