ReverseString.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Candid Java
*/
public class ReverseString {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the string");
String str = br.readLine();
char[] arr = str.toCharArray();
for (int i = 0, j = str.length() - 1; i < j; i++, j--) {
char temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
System.out.println("Reverse = " + new String(arr));
br.close();
}
}
Output
Enter the string : avaj didnac ot emoclew
Reverse = welcome to candid java