Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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
4 answers
0 votes
1 answer
asked Feb 19, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer
asked Nov 26, 2019 in Java by Nigam (4k points)
0 votes
1 answer
0 votes
1 answer
asked Nov 20, 2019 in Java by Nigam (4k points)

31k questions

32.4k answers

500 comments

693 users

Browse Categories

...