public class test {
public static void main(String[] args) {
List<Persona> list = new ArrayList<>();
list.add(new Person("test",1L));
list.add(new Person("tes2t",3L));
final Long[] total = {0L};
list.forEach(person -> {
total[0] = total[0] + person.getAmount();
});
System.out.println(total[0]);
}
}
public class Person{
private String name;
private Long amount;
}