+ 1

How to reverse user input to backward.

How to reverse when some one input is "dave" to "evad" with java.

8th Feb 2021, 12:58 PM
Dawit Teshager(Seek Boy)
Dawit Teshager(Seek Boy) - avatar
3 ответов
+ 4
Get the length of string , run a for loop with decreasing value length to 0 ,and use that value as index to print string in reverse order.
8th Feb 2021, 1:05 PM
Abhay
Abhay - avatar
+ 1
Even better... String text = "dave"; String reversed = new StringBuilder(text).reverse().toString(); https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/StringBuilder.html#reverse()
9th Feb 2021, 11:59 PM
David Ordás
David Ordás - avatar
0
Good to know .
10th Feb 2021, 12:04 AM
Abhay
Abhay - avatar