int[][] copy = new int[nums.length][];
for (int i = 0; i < nums.length; i++) {
copy[i] = new int[nums[i].length];
for (int j = 0; j < nums[i].length; j++) {
copy[i][j] = nums[i][j];
}
}
You can replace the second loop with System.arraycopy() or Arrays.copyOf().
Related Contents:
- How do I do a deep copy of a 2d array in Java?
- The best way to print a Java 2D array? [closed]
- How do I copy a 2 Dimensional array in Java?
- Java Comparator class to sort arrays
- How to convert a 1d array to 2d array?
- Is it possible to dynamically build a multi-dimensional array in Java?
- Sorting 2D array of strings in Java
- Getting the array length of a 2D array in Java
- Arrays.fill with multidimensional array in Java
- How do I create a jagged 2d array in Java?
- casting Arrays.asList causing exception: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
- Arrays constants can only be used in initializers error
- Pascal’s triangle 2d array – formatting printed output
- Matrix multiplication using arrays
- Arrays with trailing commas inside an array initializer in Java
- Multi-dimensional array transposing
- Syntax for creating a two-dimensional array in Java
- How do I remove objects from an array in Java?
- Java arrays printing out weird numbers and text [duplicate]
- Convert ArrayList to String[] array [duplicate]
- Accessing members of items in a JSONArray with Java
- Where is Java’s Array indexOf?
- “Code too large” compilation error in Java
- What is the Cost of Calling array.length
- How to convert object array to string array in Java
- Any way to declare an array in-line?
- How to convert an Array to a Set in Java
- Connect 4 check for a win algorithm
- How to convert a Java 8 Stream to an Array?
- How do I convert a byte array to Base64 in Java?
- How to make an array of arrays in Java
- byte[] to file in Java
- Converting an array of objects to an array of their primitive types
- How to create a sub array from another array in Java?
- How is length implemented in Java Arrays?
- Java: what’s the big-O time of declaring an array of size n?
- Obtaining the array Class of a component type
- How to get unique values from array
- Dealing with an ArrayStoreException
- How to use a variable of one method in another method?
- How do I convert Double[] to double[]?
- How to make HashMap work with Arrays as key?
- ArrayList: how does the size increase?
- How to access nested elements of json object using getJSONArray method
- How to clone a multidimensional array in java? [duplicate]
- How to convert byte array to hex format in Java
- How does primitive array work with new for each loop in Java?
- Sort a parallel array using Arrays.sort()
- Easiest way to convert a Blob into a byte array
- java: Arrays.sort() with lambda expression