Java / Map and its implementations
Is HashMap faster compared to ArrayList in terms of search?
The ArrayList has O(n) performance for every search, so for n searches its performance is O(n^2).
The HashMap has O(1) performance for every search (on average), so for n searches its performance will be O(n).
While the HashMap will be slower at first and take more memory, it will be faster for large values of n.
More Related questions...