Site icon NgDeveloper

String Reverse in Java Example

String Reverse Java Program:
[java]
package in.javadomain;

public class stringReverse {
public static void main(String[] args) {
String input = "DOG";
System.out.println("Original String :::" + input);
StringBuffer reverseInput = new StringBuffer(input).reverse();
System.out.println("Reversed String :::" + reverseInput);
}
}
[/java]

Output:
[plain]
Original String :::DOG
Reversed String :::GOD
[/plain]

Exit mobile version