Javatpoint Logo
Javatpoint Logo

Java Program to find Reverse of the string.

In this program, we need to find the reverse of the string. This can be done by iterating the string backward and storing each character from the original string into a new string.

ALGORITHM

  • STEP 1: START
  • STEP 2: DEFINE String string = "Dream big"
  • STEP 3: DEFINE reversedStr = " "
  • STEP 4: SET i =string.length()-1. REPEAT STEP 5 to STEP 6 UNTIL i>=0
  • STEP 5: reversedStr = reversedStr + string.charAt(i)
  • STEP 6: i = i - 1
  • STEP 7: PRINT string.
  • STEP 8: PRINT reversedStr.
  • STEP 9: END

Program:

Output:

Original string: Dream big
Reverse of given string: gib maerD
Next TopicJava Programs




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA