22
Existe-t-il un moyen concis d'itérer sur un flux avec des indices en Java 8?
Existe-t-il un moyen concis d'itérer sur un flux tout en ayant accès à l'index dans le flux? String[] names = {"Sam","Pamela", "Dave", "Pascal", "Erik"}; List<String> nameList; Stream<Integer> indices = intRange(1, names.length).boxed(); nameList = zip(indices, stream(names), SimpleEntry::new) .filter(e -> e.getValue().length() <= e.getKey()) .map(Entry::getValue) .collect(toList()); ce qui semble plutôt décevant par rapport …
382
java
java-8
java-stream