0

I am looking for a type of mutidimensional-arraylist which can be initialize by an array just like regular 2d arrays. Such as this:

for(int o = 0; o < n; o++) {
    for(int i = 0; i < n; i++) {
        num[o][i] = sc.nextInt();
    }
}

I greatly appreciate your help.

Rain
  • 37
  • 6
  • It's not in std library, you should try by yourself and paste code here if you get an error – Mead Sep 30 '18 at 03:18

1 Answers1

0

A simple 2d array could be initialized with the help of Arrays.fill(primitive[], primitive), just like this:

final int[][] arr = new int[10][10];

for (int[] brr : arr) {
        Arrays.fill(brr, 0);
}

It would generate you a 10x10 arrays with lots of zeros for you.

I found this guy here ND4J, it resembles a lot Numpy. I believe it could be useful to you too. It has a zeros method too =)

Diogo Silvério
  • 334
  • 3
  • 7
  • sorry, what I was looking for was this page. https://stackoverflow.com/questions/3642205/java-arraylist-of-arrays – Rain Oct 01 '18 at 23:12