#Got a hashMap <String,List<String>>, how do I check if any of the existing Lists contains an item?
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
the question is poorly prased. you cannot get a certain value from a map without the key. the key seams to be a string. so a string is mapped to a list of strings. correct?
Yep
I just spotted what I needed, the .containsValue() method, sorry for bothering ya
Closed the thread.
.containsValue() will require you to pass a List
and the list you pass will be matched exactly against the lists in a map
which is probably not what you want
efficiency is ignored at this point of time, just need to do it, already finished it up. Isnt this thread closed or deleted at this point tho?
Closed the thread.
ye I think I found out what you meant when half my lists went missing due to this check going off, sorry for being cocky
if you don't need to pinpoint which exact list contains foo, you can use map.values().stream().flatMap(Collection::stream).anyMatch(foo::equals)
what does everything past .stream() do?
if you're not comfortable with streams, just do a simple iterational approach instead
damn I suck, how does that approach work? some for-each loops?
thanks