
write a program reversee a string. input-hi this is roseindia output-roseindia is this hi.

Reverse String in Java
The given code reverses the position of each word in a string and stored into the StringBuffer.
import java.util.*;
public class ReverseString{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
StringBuffer buffer=new StringBuffer();
System.out.println("Enter string: ");
String str=input.nextLine();
String array[]=str.split(" ");
for(int i=array.length-1;i>=0;i--){
buffer.append(array[i]);
buffer.append(" ");
}
System.out.println("Reverse: " + buffer.toString());
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.