reverseArray method