How do I print a word backwards using Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I print a word backwards using Java?

18th Sep 2020, 8:07 PM
Manuji John
10 Answers
+ 3
Using StringBuilder wrapper String word = "Hello world!"; String reversed = new StringBuilder(word) .reverse() .toString();
18th Sep 2020, 9:20 PM
Ore
Ore - avatar
+ 1
But how?
18th Sep 2020, 8:26 PM
Manuji John
+ 1
Did you completed the loop chapter? If yes then can you show me to print a string charecter one by one.. Or post any attempt for that.. If you not completed the lessons for strings and loops then just complete first.. Don't jump farward.. You can not understood, even if I say the way, also..
18th Sep 2020, 8:32 PM
Jayakrishna 🇮🇳
+ 1
I don't know but l will try God helping me
18th Sep 2020, 8:34 PM
Manuji John
+ 1
Thank you
18th Sep 2020, 9:21 PM
Manuji John
+ 1
EliSucco if you are asking question then, condition shloud be i >= 0 to print first char also...
19th Sep 2020, 9:53 PM
Jayakrishna 🇮🇳
0
You can use a loop to track from backwards simply..
18th Sep 2020, 8:25 PM
Jayakrishna 🇮🇳
0
What ever you know, try by that first and post your try to know your understandings.. So that others help to complete the task....
18th Sep 2020, 9:22 PM
Jayakrishna 🇮🇳
0
Ok thanks
18th Sep 2020, 9:23 PM
Manuji John
0
String s = "Hello, World!"; char[] cArr = s.toCharArray(); for (int i = cArr.length - 1; i >= 0; i--) { System.out.println(cArr[i]); }
19th Sep 2020, 9:47 PM
Erix
Erix - avatar