package com.rs.test;
public class Test {
public static void main(String[] args) {
String s="altafjava";
StringBuilder rs=new StringBuilder();
for(int i=s.length()-1;i>=0;i--){
rs.append(s.charAt(i));
}
System.out.println("Original String = "+s);
System.out.println("Reversed String = "+rs);
}
}
How to reverse a string in java? |
Nice try
ReplyDelete