Here you can find the source of swap2d(Object[][] array, int c1, int r1, int c2, int r2)
Parameter | Description |
---|---|
array | The target array. |
c1 | The 1st swap column. |
r1 | The 1st swap row. |
c2 | The 2nd swap column. |
r2 | The 2nd swap row. |
public static void swap2d(Object[][] array, int c1, int r1, int c2, int r2)
//package com.java2s; public class Main { /**/*from w w w . j a v a 2 s . c o m*/ * A method for swapping matrix cells in-place. * @param array The target array. * @param c1 The 1st swap column. * @param r1 The 1st swap row. * @param c2 The 2nd swap column. * @param r2 The 2nd swap row. */ public static void swap2d(Object[][] array, int c1, int r1, int c2, int r2) { if (array == null) { throw new IllegalArgumentException("Array must not be null"); } Object swap = array[c1][r1]; array[c1][r1] = array[c2][r2]; array[c2][r2] = swap; } }