This question is essentially an addendum to this one which already asks about Java's contains() performance, but my use case targets collections with a small number of String elements.
To make the problem more precise, there will be:
- Only java.lang.Stringelements in the collection (thus usingString.equals(...)in thecontains(...)calls).
- String have average length of 16.
- The average number of elements in a single collection is 7.
- The collection will face frequent contains(...)checks, occasional additions, and no removals.
- Ordering of Strings is not important at all.
- This code would run on a web server, and there would be a large number of such collection objects (~1000 per user request).
Which collection would be a better fit for this use-case, both memory-wise and time-wise?
 
     
    