Fiserv Interview Question

How to reverse a String in Java?

Interview Answer

Anonymous

Apr 16, 2021

might be surprising, but there is no reverse() utility method in the String class. But, it’s a very simple task. We can create a character array from the string and then iterate it from the end to start. We can append the characters to a string builder and finally return the reversed string.