LongSummaryStatistics (List<String> list) { LongSummaryStatistics stat = new LongSummaryStatistics(); for (String s : list) { System.out.println(s); long length = s.length(); stat.accept(length); } return stat; }