Is there anything you can use to reverse the output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there anything you can use to reverse the output?

example String x = "hello"; System.out.println(x); i want output to be : "olleh" sknaht!

26th Jul 2017, 10:18 AM
D_Stark
D_Stark - avatar
3 Answers
+ 3
26th Jul 2017, 10:39 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar
+ 12
String x = "hello"; String reverse = new StringBuffer(x).reverse().toString(); System.out.print(reverse);
26th Jul 2017, 10:30 AM
Dev
Dev - avatar
+ 1
thanks! im guessing these work with int also changing toString() to toInt()?
26th Jul 2017, 10:39 AM
D_Stark
D_Stark - avatar