Javatpoint Logo
Javatpoint Logo

Wap to Reverse a String in Java using Lambda Expression

In Java, a String is a sequence of characters that remains immutable once created. If there's a need to reverse a user-entered string, the `charAt()` method from the String class can be employed. The method facilitates the extraction of individual characters from the string, enabling their concatenation in reverse order to achieve the desired reversal.

Moreover, the Stream API, coupled with Lambda Expressions, offers a functional and declarative means of data manipulation in Java. To reverse a String using Lambda Expressions, the common procedure entails converting the String into a character stream, implementing the reversal operation, and subsequently converting it back into a String.

Example 1

Filename: StringLambdaExample1.java

Output:

Reversed word using lambda function: tniopTavaj
Enter a string to be reversed:
A Java Website
After reversing: etisbeW avaJ A

Example 2

Filename: StringLambdaExample2.java

Output:

tniopTavaj






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA