I am trying to reverse a String input by the user. I don't think I am far off but I have been stuck for awhile and can't figure out a solution.[Disallowed URL]
public void act()
{
String user=Greenfoot.ask("Input a word or phrase");
int index=0;
while(index>=-user.length()-1)
{
showText(user.substring(-user.length(),user.length()),300,200);
index=index-1;
}
Greenfoot.stop();
}public void act()
{
String user = Greenfoot.ask("Input a word or phrase);
if (user != null)
{
StringBuilder sb = new StringBuilder(user);
sb.reverse();
showText(sb, 300, 200);
}
Greenfoot.stop();
}