DEV Community

Discussion on: Reverse a Word.

Collapse
 
_hs_ profile image
HS

why not just this
public static boolean isPalindrome(String str) {
return str.equals(new StringBuilder(str).reverse().toString());
}

Collapse
 
s_awdesh profile image
Awdesh

You are using Java's in built reverse method. Normally in an interview, you create your own algorithm i.e. your own implementation of reverse method.

Collapse
 
_hs_ profile image
HS

Oh OK these post are like examples for juniors when doing interview and stuff