Here you can find the source of swap(T[] array, int i, int len)
private static <T> void swap(T[] array, int i, int len)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Oobium, Inc./*from w ww .j av a 2s.c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation ******************************************************************************/ import java.util.List; public class Main { private static <T> void swap(T[] array, int i, int len) { T tmp = array[i]; array[i] = array[len - i - 1]; array[len - i - 1] = tmp; } private static <T> void swap(List<T> list, int i, int len) { T tmp = list.get(i); list.set(i, list.get(len - i - 1)); list.set(len - i - 1, tmp); } }