Recently, I came across a request to reverse a given string in Java. This does seem a bit odd, but nonetheless, I was asked to perform a reverse without using in-built methods, additional parameters, or any other common way. I am not sure if other companies follow this trend of not using Java API methods, but still, in interviews, companies want you to think beyond what you know and would typically do.
You may also like: The Right Way to Reverse a String in Java
Reversing a string becomes much easier with Java reverse()
in the AbstractStringBuilder
class method, which takes care of all wired scenarios.