I have \"Hello World\"
kept in a String variable named hi
.
I need to print it, but reversed.
How can I do this? I understand there
package logicprogram;
import java.io.*;
public class Strinrevers {
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter data");
String data=br.readLine();
System.out.println(data);
String str="";
char cha[]=data.toCharArray();
int l=data.length();
int k=l-1;
System.out.println(l);
for(int i=0;k>=i;k--)
{
str+=cha[k];
}
//String text=String.valueOf(ch);
System.out.println(str);
}
}