Java Program to Reverse the String

Here is a very simple java program to reverse a string….

class reverse
public static void main(String args[]) throws IOException
System.out.println(“Enter the string”);
System.out.println(“================= “);
System.out.println(”                   “);
DataInputStream z=new DataInputStream(;
String str=z.readLine();
StringBuffer sb=new StringBuffer(str);
System.out.println(“the given string is = ” + str);
System.out.println(”   “);
System.out.println(”   “);
System.out.println(“the Reversed String is =” + sb.reverse());

Add Comment