Make your own free website on Tripod.com

// print out int in reverse order
// illustration of using Integer Wrapper Class
// convert integer to Integer - then convert it to
// a string - then print string out in reverse



import java.io.*;

public class wrapperTest
{static input in = new input();

public static void printreverse(int n)
 {Integer n2 = new Integer(n);
  String s = n2.toString();
  for (int x = s.length() - 1; x >= 0; x--)
   System.out.print(s.substring(x,x+1));
 }


public static void main(String [] args) throws IOException
   {int n;
    System.out.println("Enter a number ");
    n = in.getInt();
    printreverse(n);
    }
}