Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamToLoop/afterInLambda.java
Tagir Valeev 7e1064ea3c [java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
2022-07-29 17:55:13 +00:00

28 lines
698 B
Java

// "Replace Stream API chain with loop" "true-preview"
import java.util.Objects;
import java.util.function.DoubleSupplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main {
public void test(String... list) {
DoubleSupplier s = () -> {
long sum = 0;
long count = 0;
for (String s1 : list) {
if (s1 != null) {
sum += s1.length();
count++;
}
}
return count > 0 ? (double) sum / count : 0.0;
};
System.out.println(s.getAsDouble());
}
public static void main(String[] args) {
new Main().test("a", "bbb", null, "cc", "dd", "eedasfasdfs");
}
}