IDEA-160802 fixed case with collection summing

This commit is contained in:
Tagir Valeev
2016-09-08 16:53:51 +07:00
parent e7309e1455
commit c4b6464524
3 changed files with 36 additions and 5 deletions
@@ -0,0 +1,14 @@
// "Replace with sum()" "true"
import java.util.List;
public class Main {
interface Person {
int getAge();
}
public long test(List<Person> collection) {
long i = collection.stream().mapToLong(Person::getAge).sum();
return i;
}
}
@@ -0,0 +1,17 @@
// "Replace with sum()" "true"
import java.util.List;
public class Main {
interface Person {
int getAge();
}
public long test(List<Person> collection) {
long i = 0;
for(Person person : collecti<caret>on) {
i = i + person.getAge();
}
return i;
}
}