Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (3.9k points)
I have "Hello World" kept in a String variable named hi.

I need to print it but reversed.

How can I do this? I understand there is some kind of a function already built-in into Java that does that.

1 Answer

0 votes
by (46k points)

You can try:

new StringBuilder(hi).reverse().toString()

Or, toward versions earlier than JDK 1.5, try java.util.StringBuffer rather than StringBuilder — both possess the same API. StringBuilder is favored nowadays as there's no concurrency matter.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 6 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer
asked Nov 26, 2019 in Java by Nigam (4k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...