Program:
package JavaCoders;import java.util.Scanner;
public class rev_string
{
public static void main(String[] args)
{
String str1="";
String str2="";
System.out.println("Enter the string to be reversed:\n");
Scanner scn=new Scanner(System.in);
str1=scn.next();
for(int i=str1.length()-1;i>=0;i--)
{
str2=str2+str1.charAt(i);
}
System.out.println("Reversed String is: "+str2);
}
}
OUTPUT:
You can also go to link that ellaborate it more:
Well explained string operation .
ReplyDeletethere are good String program collection visit Top String program