I have an assignment for my Computer Science course and our instructor wants us to use Stream and Lambda expressions for an iterator. I haven't seen the warning and I wrote the needed code according to my own taste and here it is:
static List<User> getUsers(String firstName){
Iterator<User> it = users.iterator();
ArrayList<User> tempList = new ArrayList<User>();
while(it.hasNext()){
User tempUser = it.next();
if(tempUser.getFirstName().equals(firstName)){
tempList.add(tempUser);
}
}
return tempList;
}
How can I turn this into a Stream & Lambda code? Thanks so much for your answers.