I am studying programming 101 with Java and I am really stuck with this assignment:
"Create a program that asks for the user's name and prints it in reverse order. You do not need to create a separate method for this.
Type your name: Paul In reverse order: luaP
Type your name: Catherine In reverse order: enirehtaC"
I can't figure out why my code gives wrong results. Here is my code thus far:
import java.util.Scanner;
public class ReversingName {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
    System.out.println("Type a name:");
    String name = reader.nextLine();
    int i = name.length();
    while (i > 0){
        char character = name.charAt(i);
        System.out.print(character);
        i--;
    }
}
}
 
     
     
    