Monday, 12 September 2011

Reverse the String


public class ReverseString {
    public static void main(String[] args) {
        System.out.println("ReverseString\n");
        String revString = new String();
        revString = "Mathematics";
        char[] chrArray = revString.toCharArray();
       
        for(int i = chrArray.length-1 ; i >=0 ; i--){
            System.out.print(chrArray[i]);
        }
    }
}

No comments:

Post a Comment