public StrBuilder reverse ( ) { if ( size == 0 ) { return this ; } final int half = size / 2 ; final char [ ] buf = buffer ; for ( int leftIdx = 0 , rightIdx = size - 1 ; leftIdx < half ; leftIdx ++ , rightIdx -- ) { final char swap = buf [ leftIdx ] ; buf [ leftIdx ] = buf [ rightIdx ] ; buf [ rightIdx ] = swap ; } return this ; }
Reverses the string builder placing each character in the opposite index .