Reverse a String with StringBuilder or StringBuffer

September 15th, 2006 Admin Posted in Java No Comments »

Both StringBuilder and StringBuffer class have a reverse method. They work pretty much the same, except that methods in StringBuilder are not synchronized. This is the signature of StringBuilder.reverse:
public StringBuilder reverse()
This method returns an instance of StringBuilder. The interesting thing is, the returned value is actually itself. So what this method does is, it reverses itself

AddThis Social Bookmark Button