Here you can find the source of swap(List list, int firstIndex, int secondIndex)
Parameter | Description |
---|---|
firstIndex | the index of the first row |
secondIndex | the index of the second row |
protected static void swap(List list, int firstIndex, int secondIndex)
//package com.java2s; /*//w w w. j ava 2 s .c o m * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.List; public class Main { /** * Swaps the two rows. * * @param firstIndex the index of the first row * @param secondIndex the index of the second row */ protected static void swap(List list, int firstIndex, int secondIndex) { Object backup; backup = list.get(firstIndex); list.set(firstIndex, list.get(secondIndex)); list.set(secondIndex, backup); } }