Reverse a String using CharAt(i)
public class ReverseString{ public static void main(String args[]) { String original="Hello"; String rev=""; int len=original.length(); for(i=len-1;i>=0;i--){ rev=rev+original.charAt(i) } System.out.println("original String is"+original); System.out.println("reverse String is"+rev); }}
No comments:
Post a Comment