0

Can any one please tell me how to print backwards of it like. R E T U P M O C

https://code.sololearn.com/c5u2gNgw5EK2/?ref=app

24th Apr 2022, 9:09 AM
ALI IMRAN
ALI IMRAN - avatar
3 Answers
+ 3
You are almost there. Just start at a-1, reverse the terminating condition and count down not up. If you do not want the line break, then use print in lieu of println. for(int i = a-1 ; i >= 0 ; i--) { System.out.print(str1.charAt(i)); } I would also like to point your attention towards the StringBuilder class which has a reverse method. Ideal to use in a method that returns a reverse string instead of printing it. Makes your code more flexible and reusable.
24th Apr 2022, 9:19 AM
Ani Jona šŸ•Š
Ani Jona šŸ•Š - avatar
+ 3
Thanks Ani.šŸ’Æ
24th Apr 2022, 9:22 AM
ALI IMRAN
ALI IMRAN - avatar
+ 3
You're welcome :)
24th Apr 2022, 9:29 AM
Ani Jona šŸ•Š
Ani Jona šŸ•Š - avatar