StreamToLoopInspection: reuse existing variable if we should reassign it in loop, but it's possible to use it as non-final

This commit is contained in:
Tagir Valeev
2016-12-23 13:30:08 +07:00
parent 4a2a11c85f
commit 1e33755e09
12 changed files with 147 additions and 27 deletions

View File

@@ -1,12 +1,14 @@
// "Replace Stream API chain with loop" "true"
import java.util.List;
import java.util.function.LongSupplier;
public class Main {
private static void test(List<String> list) {
long count = list.stream().filter(s -> !s.isEmpty()).co<caret>unt();
if(count > 10) {
long result = count*2;
LongSupplier sup = () -> count*2;
long result = sup.get();
System.out.println(result);
}
}