Java ArrayList Swap swap(ArrayList numbers, int i, int j)

Here you can find the source of swap(ArrayList numbers, int i, int j)

Description

swap

License

Open Source License

Declaration

public static void swap(ArrayList<Integer> numbers, int i, int j) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static void swap(int[] numbers, int i, int j) {
        int temp = numbers[i];
        numbers[i] = numbers[j];//from   w ww  .ja v  a2  s  .c o m
        numbers[j] = temp;
    }

    public static void swap(ArrayList<Integer> numbers, int i, int j) {
        int temp = numbers.get(i);
        numbers.set(i, numbers.get(j));
        numbers.set(j, temp);
    }

    public static void swap(ArrayList<Integer>[] numbers, int i, int j) {
        ArrayList<Integer> temp = numbers[i];
        numbers[i] = numbers[j];
        numbers[j] = temp;
    }
}

Related

  1. swap(ArrayList dataStrs, int i, int j)
  2. swap(ArrayList data, int i, int j)
  3. swapRemove(ArrayList list, int index)