Hi, thanks for this video. A small clarification. You say (minute 02:56) that map didn't have any terminal operations. But, as far as I can see, map has terminal operations, like for example count. I guess it can't have sum just because with map you can map from a generic type T to a generic type S, and it's not guaranteed that the sum operation is defined in the domain of T objects; while, if you use mapToInt (and similar) you have this operation for sure.
Hi, Nice video.. How can we use RegEx with Map? I have a list of string with Pattern. I would like to do a exact match for a word in that list of string and return true if so. I tried as below. Please suggest if there is a better way. strList.stream().map(s -> regexMatcher(regex, s)).collect(Collectors.toSet()).contains("searchWord")
if you just need exact match of the words you dont even need to iterate whole list. you can do it more efficiently with filters and optional Optional optional = strList.stream().filter(name -> name.equals("searchWord").findFirst(); optional.isPresent() -> returns true or false.
Hi, thanks for this video. A small clarification. You say (minute 02:56) that map didn't have any terminal operations. But, as far as I can see, map has terminal operations, like for example count. I guess it can't have sum just because with map you can map from a generic type T to a generic type S, and it's not guaranteed that the sum operation is defined in the domain of T objects; while, if you use mapToInt (and similar) you have this operation for sure.
Hi, Nice video.. How can we use RegEx with Map? I have a list of string with Pattern. I would like to do a exact match for a word in that list of string and return true if so. I tried as below. Please suggest if there is a better way.
strList.stream().map(s -> regexMatcher(regex, s)).collect(Collectors.toSet()).contains("searchWord")
if you just need exact match of the words you dont even need to iterate whole list. you can do it more efficiently with filters and optional
Optional optional = strList.stream().filter(name -> name.equals("searchWord").findFirst();
optional.isPresent() -> returns true or false.
Thanks. Simple and to he point explanation.
Thanks! You helped me out!)