StreamToLoop: reuse variable if possible when the stream is used in the declaration

This commit is contained in:
Tagir Valeev
2016-12-12 17:22:51 +07:00
parent 810445f21d
commit e87c551445
6 changed files with 85 additions and 61 deletions

View File

@@ -5,8 +5,9 @@ import java.util.stream.Collectors;
public class Main {
public static Map<Integer, String> test(List<String> strings) {
return strings.stream()
Map<Integer, String> mapping = strings.stream()
.co<caret>llect(Collectors.toMap(String::length, str -> str));
return mapping;
}
public static void main(String[] args) {