Sunday, September 15, 2019

Java Program 6: How to reverse a String in Java?

In this post we will discuss different methods to reverse a String in java programming.

Method 1:

Step 1: Read the input string using "Scanner" class

Step 2: Create a method that takes the given string and returns reversed string

Step 3: In the "reverse()" , convert the string to character array. Then, use for loop and add each character to the variable 'String reversed = "";'

Step 4: Return the reversed string and print it in the main method.

Check the complete program below:

Thanks for reading. #KeepLearning #KeepSharing

3 comments:

  1. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! Kopar at Newton CEL Development

    ReplyDelete
  2. frases You did really good work. I really appreciate your new and different post. Please guys keep it up and share with us some unique post in the future   

    ReplyDelete

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...