Question: I am working on a program where I take input from the user and I the enter 24 length `String` with numbers 0-5 and each number is repeated 4 times in the line. An example would be like this `000011112222333344445555`. I realized when I am collecting the numbers for the user that I can't have them in a `2d int array of [6][4]`. Which is what I want so what I want to do is take that string and put the each of the numbers in that array. So it would look like this `[[0,0,0,0],[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4],[5,5,5,5]]`. I am not sure how to get them into an array like this. I know that strings are immutable so I can't change the string but I did think I could take the string and turn it into `char` array and then insert each value into my desired int array. I don't know how to do this any help or guidance on how to approach this would be really appreciated. Thanks in advance

Answer: 
You can get your 2d array with a one liner:

```
int[][] numbers = Arrays.stream("000011112222333344445555".split("(?<=\\G.{4})")).map(s -> (Arrays.stream(s.split("(?<=\\G.{1})")).mapToInt(Integer::parseInt).toArray())).toArray(int[][]::new);

```
So its fairly easy thing to do.

```
lets assume your string is str;

char[] strArr = str.toCharArray();

// numbers is the range like 0 to 5 here.
// repeatCount is how many times its repeating like 4 here.

int arr[][] = new int[numbers][repeatCount];

for(int i = 0; i < numbers; i++){
    for(int j = 0; j < repeatCount; j++){
         arr[i][j] = strArr[i*repeatCount + j]-'0';
    }
}

```

Lastly a precaution, this function will work only if your numbers are single digit, as only one char is being picked.