how to get values from list object in java 8 code example
Example 1: java stream find specific element
Customer james = customers.stream()
.filter(customer -> "James".equals(customer.getName()))
.findAny()
.orElse(null);
Example 2: find object with same attribute java stream
Optional<Person> matchingObject = objects.stream().
filter(p -> p.email().equals("testemail")).
findFirst();
Example 3: how to get elements of a list in java
int num = list.get(0);