How do I convert a Java 8 lambda string to 7?

  • 0
    Yes Function
    private void addAllOrderedStocksToList(List<Integer> list) {
            Iterator<Integer> amountIterator = data.getNumberOfOrderedStacks().iterator();
            Iterator<Integer> lengthIterator = data.getOrderedStackLengths().iterator();
           while (amountIterator.hasNext()) {
              int amount =;
              int length =;
               IntStream.range(0, amount).forEach(x -> list.add(length));   

    The problem I am having is this line. I don't understand what she does at all.
    IntStream.range (0, amount) .forEach (x - & gt; list.add (length));
    Can anyone help me to remake it in Java 7.
    Java Anonymous, Mar 31, 2020

  • 1 Answers
  • 0
    Java 7 doesn't have Stream Api. Rewrite the for loop from zero to amount, and in the body of the loop add length to list.
    Sebastian Ruiz

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!