Java Online Compiler
Example: String Reverse in Java using Stream
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// String Reverse in Java using Stream import java.util.Scanner; import java.util.stream.Collectors; import java.util.stream.Stream; 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 reverse the input string String reverseStr=Stream.of(x) .map(str -> new StringBuilder(str).reverse()) .collect(Collectors.joining()); // It will print the final output System.out.println("The reverse of the string is:: "+reverseStr+"\n"); } }
Hello w3codeworld
Output
Clear
ADVERTISEMENTS