So just to give a little direction, Ihave this assignment where I am supposed to print out the reverse of the input. Ex: If someone types in dylan it prints out nalyd. I'm also supposed to accomplish this using for loops and sub strings.
Here's my code:
Scanner kb = new Scanner (System.in);
String name;
System.out.println("What is your name?");
name = kb.next();
int x = name.length();
for (name.substring(x,x); x>-1; x-=1)
{
System.out.print(name.substring(x));
}
This will print out "nanlanylanDylan" but obviously thats not what I want. Just looking for a way to remedy this, I understand I could use other methods like charAt and such but I'm trying to use just substrings.