Thursday, August 16, 2018

How to reverse a string in java?



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?
How to reverse a string in java?




Share this

1 Response to "How to reverse a string in java?"