void (String... list) { DoubleSupplier s = () -> { long sum = 0; long count = 0; for (String string : list) { if (string != null) { sum += string.length(); count++; } } return count > 0 ? (double) sum / count : 0.0; }; System.out.println(s.getAsDouble()); }