how to generate this list 1 2 2 4 8 32 in java
Answers
Answered by
0
Answer:
The following one-liner Java 8 version will generate [ 1, 2 ,3 ... 10 ]. The first arg of iterate is the first nr in the sequence, and the first arg of limit is the last number. List<Integer> numbers = Stream.iterate(1, n -> n + 1) .limit(10) .collect(Collectors.toList()); Share. Follow answered Mar 20 '16 at 14:04. Catalin Ciurea Catalin Ciurea. 611 1 1 gold badge 9 9 silver badges 7 7 ..
Explanation:
brainliest pls
Similar questions