集册 Java实例教程 随机二维数组

随机二维数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

528
随机二维数组

/*来自 
 N  o w  J a v a . c o m*/

//package com.nowjava;


import java.util.Random;


public class Main {

    public static <T> T[][] shuffle(T[][] input) {

        int j;

        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[
展开阅读全文