Well, not very sure of the declarations used for the variables used in your code shared, but to transform the above code to use IntStream
, you can attempt something like(declarations mine) :
final int[] modifiedNumber = {123};
final int len = String.valueOf(modifiedNumber[0]).length();
ArrayList<Integer> aList = new ArrayList<>();
final int[] count = {0};
IntStream.range(0,len).forEach(mn -> {
double pow = Math.pow(10, count[0]);
int tempNumber = (int) ((modifiedNumber[0] % 10) * pow);
aList.add(tempNumber);
modifiedNumber[0] = modifiedNumber[0] / 10;
count[0]++;
});
System.out.println(aList);
Note: Most of the integer values are converted to final single valued array to be consumed within the streams.