Java Programming Exercise : Reverse string char order

This article will show give you an exercise and solution for you.
Exercise: Get input from keyboard and show the reverse order of input.
Example: Input: asdf              Result:  fdsa
Hint: using string, scanner, chartAt.

Solution:
import java.util.Scanner;


public class ReverseOrderofString {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  
  String input;
  String reverse="";
  
  System.out.print("Input a sentence: ");
  Scanner myScanner = new Scanner(System.in);
  
  input = myScanner.nextLine();
  
  for(int i=input.length()-1; i>=0;i--){
   reverse+=input.charAt(i);
  }
  
  System.out.println(reverse);
 }

}