Below is the example of the code snippet which needs the help
Example:
[1,2,3,4,5]
1,
If you don't mind importing Google Guava and converting to a List, there is a method for partitioning Lists:
https://google.github.io/guava/releases/27.1-jre/api/docs/com/google/common/collect/Lists.html#partition-java.util.List-int-
The following may achieve the desired result:
List listToBeSplit = Arrays.asList(sourceArray);
int chunkSize = 3;
Lists.partition(listToBeSplit, chunkSize);