Suppose to have a class Obj
class Obj{
int field;
}
and that you have a list of Obj
instances, i.e. List<Obj> lst
.
Now, how can I find in Java8 the minimum value of the int fields field
from the objects in list lst
?
You can also do
int min = list.stream().mapToInt(Obj::getField).min();