int lastElement = values[values.length-1]; values[values.length-1] = values[0]; values[0] = lastElement;