Here you can find the source of swap(Object[] arr, int a, int b)
Parameter | Description |
---|---|
arr | the array we need to manipulate |
a | a parameter |
b | a parameter |
public static void swap(Object[] arr, int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { public static void swap(Object[] arr, int a, int b) { Object tempObj = arr[a];// w w w .java 2s . com arr[a] = arr[b]; arr[b] = tempObj; } public static void swap(int[] arr, int a, int b) { int temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(double[] arr, int a, int b) { double temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(float[] arr, int a, int b) { float temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(long[] arr, int a, int b) { long temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(short[] arr, int a, int b) { short temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(char[] arr, int a, int b) { char temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } public static void swap(byte[] arr, int a, int b) { byte temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } }