Java Array Swap swapAndPrint(int[] arr, int m, int n)

Here you can find the source of swapAndPrint(int[] arr, int m, int n)

Description

swap And Print

License

Open Source License

Declaration

public static void swapAndPrint(int[] arr, int m, int n) 

Method Source Code

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

public class Main {
    public static void swapAndPrint(int[] arr, int m, int n) {
        int temp = arr[m];
        arr[m] = arr[n];/*  w w w  .  j  a va2 s  . com*/
        arr[n] = temp;

        print(arr);

    }

    public static void print(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println("");
    }
}

Related

  1. swap(T[] ts, int i, int j)
  2. swap2(double v[], int v2[], int i, int j)
  3. swap2Bytes(byte[] bytes, int offset)
  4. swap3(String[] a, int x, int y, int z)
  5. swapAll(final Object[] array)
  6. swapArray(int[] v, int i, int j)
  7. swapArrayStr(String[] arr)
  8. swapArrayValues(int i1, int i2, int[] indices)
  9. swapBlocks(byte[] array, int fromA, int toA, int fromB, int toB)