fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc = new Scanner(System.in);
  13.  
  14. String hold = "";
  15. int j = 0;
  16.  
  17. System.out.print("Enter a number: ");
  18. hold = sc.next();
  19.  
  20.  
  21. String test = "";
  22.  
  23.  
  24. for(int i = hold.length() - 1 ; i >= 0 ; i--) {
  25. test += hold.charAt(i);
  26. }
  27.  
  28. System.out.print(test);;
  29.  
  30. sc.close();
  31. }
  32. }
Success #stdin #stdout 0.14s 37360KB
stdin
0123456789
stdout
Enter a number: 9876543210