How to deep copy 2 dimensional array (different row sizes)

前端 未结 4 1761
一向
一向 2020-12-06 13:24

This is my first question in a community like this, so my format in question may not be very good sorry for that in the first place.

Now that my problem is I want to

4条回答
  •  臣服心动
    2020-12-06 14:11

    You might need something like this:

    public class Example {
      public static void main(String[] args) {
    
        int[][] envoriment = {{1, 1, 1, 1}, {0, 1, 6}, {1}};
    
        int[][] copyArray = new int[envoriment.length][];
        System.arraycopy(envoriment, 0, copyArray, 0, envoriment.length);
      }
    }
    

提交回复
热议问题