I have a String that contains arrays. Example:
"[[1, 2], [4, 5], [7, 8]]"
Now I want to make a Java array from this. I created a function to get the dimensions and a recursive function to get each element of the array. So I have every 1-D array, but I would like to know if there is a way in Java to create a dimension array that I found at runtime? Dimension is returned as an array. For example, for the above example, the size is:
[3, 2]
EDIT: Is there a way to create a real array from this information? The measurement [3, 2] is just an example. I can have [3, 2, 4, 5]. Can an array be generated from this information at runtime? I do not have this information at compile time.
There is some problem, I can not comment on the answers. So, I am editing here.
java arrays dynamic multidimensional-array
Rishi
source share