Java examples for Collection Framework:Array Dimension
shuffle two dimensional array
//package com.java2s; import java.util.Random; public class Main { public static <T> T[][] shuffle(T[][] input) { int j;//from w w w. ja v a 2 s .c o m Random seed = new Random(System.nanoTime()); T[][] cloned = input.clone(); for (int i = cloned.length - 1; i > 0; i--) { j = seed.nextInt(i); for (int k = 0; k < cloned[i].length; k++) { T c = cloned[i][k]; cloned[i][k] = cloned[j][k]; cloned[j][k] = c; } } return cloned; } }