Simple way using StringBuilder
IntuitionWe are given an array of integers, and we need to split each number into its individual digits and collect all those digits into a single array.
For ex
# Intuition
We are given an array of integers, and we need to split each number into its individual digits and collect all those digits into a single array.
For example, if we get 83, we separate it into 8 and 3. So we do this for each number in the input array.

---


# Approach
We use a StringBuilder to convert each number into a string, so we can loop through its digits.

We subtract '0' from each character to convert the character digit to an integer digit.

We use an ArrayList to store all digits as we go.
Finally, we copy the values from the ArrayList into an int[] array and return it.


# Code
```java []
class Solution {
    public static int[] separateDigits(int[] nums) {
        
        ArrayList<Integer> al = new ArrayList<>();
        
        for (int i = 0; i < nums.length; i++) {
            StringBuilder sb = new StringBuilder(Integer.toString(nums[i]));
            
            for (int j = 0; j < sb.length(); j++) {
                al.add(sb.charAt(j) - '0');
            }
        }
        
        int[] ans = new int[al.size()];
        for (int i = 0; i < al.size(); i++) {
            ans[i] = al.get(i);
        }

        return ans;
    }

}
```
['Java']