Multidimensinal阵列添加到使用Java数组列表 [英] Add Multidimensinal array to an array list using Java

查看:196
本文介绍了Multidimensinal阵列添加到使用Java数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法(函数)是应该一(8 * 6)阵列添加到一个数组列表。函数被调用多次。

I am having a method(function) that is supposed to add a (8*6)Array to an Array list. Function is called several times.

int [][] KeySelection = new int [8][7];

  for(int i=0;i<KeySelection.length;i++){
  for(int j=0;j<KeySelection[0].length;j++){
      KeySelection[i][j] = (int) (Math.random () * 2);

     }
  }

每个这个函数被调用了一个全新的 KeySelection 阵列的时间就完成了。我现在需要的是要声明一个数组列表,以便它可以存储在该列表中的所有 KeySelection 阵列。

Each time this function is called a totally new KeySelection Array is done. What i need now is to declare an array list so that it could store all the KeySelection Arrays in that list.

这样,当我需要先 KeySelection 表我可以在数组列表的第一个索引中找到它。可能有人帮助

So that when i need the first KeySelection Table i could find it in the first index of the Array list. Could somebody Help

推荐答案

创建一个的ArrayList 类型 INT [] [] : -

Create an ArrayList of type int[][]: -

List<int[][]> list = new ArrayList<int[][]>();

然后,您的阵列添加到这个列表创建后: -

And then, add your array to this list after creation: -

list.add(keySelection);

注: - 变量名称应该开始与小写字母

NOTE: - Variable name should start with lowercase letters.

这篇关于Multidimensinal阵列添加到使用Java数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆