Creating arraylist of arrays

后端 未结 5 1919
误落风尘
误落风尘 2021-01-13 03:34

I\'m trying to create an array list of string arrays. When I am done, I want the array list to look like this:

[0,0], [0,1], [1,0], [1,1,]

5条回答
  •  -上瘾入骨i
    2021-01-13 04:32

    This is because you're adding t2 to all of the entries. Each time you overwrite t2 you're changing all the values. This is because t2 isn't being passed by value, it is being passed by reference and saved by reference.

提交回复
热议问题