public static < T > T [ ] reverse ( T [ ] array ) { if ( array == null ) return array ; int s = 0 ; int e = array . length - 1 ; while ( s < e ) { // swap index e and s T tmp = array [ e ] ; array [ e ] = array [ s ] ; array [ s ] = tmp ; s ++ ; e -- ; } return array ; }
Reverses the array in place .