Here you can find the source of swapColumns(double[][] front, int colA, int colB)
public static void swapColumns(double[][] front, int colA, int colB) throws Exception
//package com.java2s; //License from project: LGPL public class Main { public static void swapColumns(double[][] front, int colA, int colB) throws Exception { if (front.length == 0 || (colA > front.length) || (colB > front.length)) throw new Exception("Selected dimensions exceed front size"); else {/*from w w w . jav a2 s . c om*/ int setPointMin = Math.min(colA, colB); int setPointMax = Math.max(colA, colB); for (int i = 0; i < front.length; i++) { double back = 0.0; for (int j = 0; j < front[0].length; j++) { if (j == setPointMin) { back = front[i][j]; front[i][j] = front[i][setPointMax]; } if (j == setPointMax) { front[i][j] = back; } } } } } }