Java Online Compiler
Example: String Reverse in Java using StringBuilder's Built-in Method reverse()
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// String Reverse in Java using StringBuilder's Built-in Method reverse() 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 `StringBuilder` class StringBuilder SBinput=new StringBuilder(); SBinput.append(x); // To append the value of x variable // It will reverse the input value SBinput.reverse(); // It will print the final output System.out.println("The reverse of the string is:: "+SBinput+"\n"); } }
Welcome to w3codeworld
Output
Clear
ADVERTISEMENTS