How can I get the last element of a stream or list in the following code?
Where data.careas is a List:
data.careas
List
CArea f
Another way to get the last element is by using sort.
Optional<CArea> num=data.careas.stream().sorted((a,b)->-1).findFirst();