 <p>StringBuffer has a reverse: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html#reverse()" rel="nofollow noreferrer">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html#reverse()</a></p> <p>BTW, I assume you meant O(n) because O(1) (as other people have mentioned) is obviously impossible.</p>