1

How to declare 2 dimensional Dynamic array in Kotlin?

I am trying to do it with ArrayList but it fails

var dynamicarray =ArrayList<Int>(4,{ArrayList<Int>(3)}) //error

It works fine for array but not for ArrayList

var staticarray = Array(4,{IntArray(3)}) // no error
Isac
  • 1,834
  • 3
  • 17
  • 24
mike
  • 17
  • 5
  • I'm not quite sure if it's an exact duplicate. In this question, the two-dimentional array/list is initialized upon construction, while the linked one is about creating an empty list. – hotkey Mar 14 '18 at 13:02

0 Answers0