Java Online Compiler
Example: String Reverse in Java using StringBuffer
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// String Reverse in Java using StringBuffer import java.util.Scanner; public class Main { // It's the driver function public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter a string to make reverse::\n"); String x=in.nextLine(); // It will create the instance of the `StringBuffer` class StringBuffer SBuffInput=new StringBuffer(x); // It will reverse the input value SBuffInput.reverse(); // It will print the final output System.out.println("The reverse of the string is:: "+SBuffInput+"\n"); } }
Hello w3codeworld
Output
Clear
ADVERTISEMENTS