LongSummaryStatistics (List<List<String>> list) { LongSummaryStatistics stat = new LongSummaryStatistics(); for (List<String> a : list) { if (a != null) { for (String s : a) { long length = s.length(); stat.accept(length); } } } return stat; }