How do I print a word backwards using Java? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How do I print a word backwards using Java?

18th Sep 2020, 8:07 PM
Manuji John
10 Respostas
+ 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