How to reverse a string in Java?

DWQA QuestionsCategory: QuestionsHow to reverse a string in Java?
Editor Staff asked 4 weeks ago

How to reverse a string in Java?

1 Answers
Editor Staff answered 4 weeks ago

“String str = “”Hello””;
String reverse(String str){
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.reverse();
return sb.toString();
}”