DEV Community

Discussion on: Reverse String in one line

Collapse
 
wldomiciano profile image
Wellington Domiciano

Cool! Collector is very powerful.

I think the easiest way to reverse a string is to use a StringBuilder like this:

public static String reverse(String str) {
  return new StringBuilder(str).reverse().toString();
}
Enter fullscreen mode Exit fullscreen mode