![]() ![]() You could collect the users in a collection that only accepts one item, for example: User match = users.stream().filter((user) -> user.getId() > 1) The exception is thrown by Optional#get, but if you have more than one element that won't help. Take this code: public static void main(String args) ) I want to guarantee, however, that there is one and only one match to the filter criteria. I am trying to use Java 8 Streams to find elements in a LinkedList.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |