Drop Down

Monday, February 4, 2019

Reverse String Custom

package interview;


public class ReverseString_Custom {

public static void main(String[] args)
{
 
  String orig = "This is a Tree";
  String rev = "";
  int len = orig.length();
  for(int i = len-1;i>=0;i--)
  {
  rev = rev + orig.charAt(i);
  }
  System.out.println(orig);
  System.out.println(rev);
}

}

No comments:

Post a Comment

Java 8 Notes Pics