Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

I am using java8's stream.filter() method which takes a predicate and return filtered stream which passes the logic in predicate

$
0
0

`There's a employee list, first 4 characters shows employee joining year. I want to get all employees who joined in 2023. I'm using java , stream and filter method to do this.

but filter() method, filtering the records but returning duplicate value. e.g in this 3 employees who joined in 2023 but i'm getting all employees twice hence getting 6 records[Employee class](https://i.sstatic.net/BHaXuXRz.png)[project class](https://i.sstatic.net/19U4NXu3.png)[Employee list](https://i.sstatic.net/3KJmj0xl.png)[result](https://i.sstatic.net/84Dgd7TK.png)Anyone help me to get understand why duplicate records are comingafter filter() method, I should get only 3 records`

Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>