Reputation: 18741
I need to create a Java structure to store a large number of String
. Then I basically need to add new strings and also check if some string is already present... The order of the strings is not important.
I don't know many Java datatypes but the typical List
, Set
and Map
, so... what would be the fastest datatype for this scenario? May it be a TreeSet
or is there any other I'm missing?
Upvotes: 2
Views: 1825
Reputation: 133587
It depends on which kind of access you need.
LinkedList<String>
ArrayList<String>
HashSet<String>
(this is the one you are looking for according to your reqs)TreeSet<String>
Upvotes: 6