This is probably a simple question for you JAVA experts, but I’m relatively new, so I thought I’d ask. I need to test if string X exists in a set. I don’t need any associated values or indices, and I don’t need any order. I just need to know if it exists. I know that this could be implemented using a HashMap or ArrayList, but those seem overkill. What to do? Just a List? Or is there something even more basic that would serve the same purpose. What is the fastest way to test if some string X exists in a given set?
Share
Sounds like you want a
HashSet<String>:There are other
Setimplementations available, of course, butHashSetis probably the most appropriate here.