How can I create a 2 dimensional dynamic length array?

后端 未结 3 1269
青春惊慌失措
青春惊慌失措 2021-01-05 05:44

I want to create a 2-dimensional array, without knowing the size of the first dimension.

For example I have an unknown number of rows, when I create an array. Ever

3条回答
  •  失恋的感觉
    2021-01-05 06:25

    As long as I know, we cant instantiate array without knowing its size. Why dont you try a Array of List? Like this:

    List[] a = new List[yourDesireColumnNumber];
    

    With List, add, select, input elements is trivial. If you want to give it as parameter in other functions, just define Type.

提交回复
热议问题