public static int run(String exp) {
.
.
if (needToCompound) {
String[] bits = exp.split(" \\+ ");
return Integer.parseInt(bits[0]) + run(bits[1]);
}
.
.
}

if (needToCompound) {
String[] bits = exp.split(" \\+ ");
String newExp = Arrays.stream(bits) // Stream<String>
.mapToInt(Calc::run) // IntStream
.mapToObj(e -> e + "") // Stream<String>
.collect(Collectors.joining(" + "));
return run(newExp);
}
