Community
Participate
Working Groups
There are a number of new Stream APIs like the #filter, #collect, #forEach, #count, #mapToInt, #mapToDouble etc. We need to analyze the existing code and propose appropriate quick assist. Like for e.g: private static void streamA(Collection<String> words) { int sum = 0; for (String word : words) { if (word.startsWith("A")) { sum++; } } System.out.println(sum); } Can be converted as: private static void streamA(Collection<String> words) { int sum = (int) words.stream().filter(w -> w.startsWith("A")).count(); System.out.println(sum); } Since there are many use cases we can create individual bugs to track each case. Also it would be nice to have a clean up option available to migrate existing code to use the new Stream APIs.
*** Bug 433028 has been marked as a duplicate of this bug. ***
*** Bug 461455 has been marked as a duplicate of this bug. ***
(In reply to Manju Mathew from comment #0) > There are a number of new Stream APIs like the #filter, #collect, #forEach, > #count, #mapToInt, #mapToDouble etc. We need to analyze the existing code > and propose appropriate quick assist. > > Like for e.g: > private static void streamA(Collection<String> words) { > int sum = 0; > for (String word : words) { > if (word.startsWith("A")) { > sum++; > } > } > System.out.println(sum); > } > Can be converted as: > private static void streamA(Collection<String> words) { > int sum = (int) words.stream().filter(w -> w.startsWith("A")).count(); > System.out.println(sum); > > } Interesting. When I did this conversion automatically in NetBeans 8.0.2, I got this: int sum = words.stream().filter((word) -> (word.startsWith("A"))).map((_item) -> 1).reduce(sum, Integer::sum);