Answer the question
In order to leave comments, you need to log in
How to convert string with Java 8 lambda to 7?
Have Function
private void addAllOrderedStocksToList(List<Integer> list) {
Iterator<Integer> amountIterator = data.getNumberOfOrderedStacks().iterator();
Iterator<Integer> lengthIterator = data.getOrderedStackLengths().iterator();
while (amountIterator.hasNext()) {
int amount = amountIterator.next();
int length = lengthIterator.next();
IntStream.range(0, amount).forEach(x -> list.add(length));
}
}
Answer the question
In order to leave comments, you need to log in
Java 7 doesn't have Stream API. Rewrite the for loop from zero to amount, and in the body of the loop add the length value to the list list.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question