I am wondering which in better guava's multiset and multipmap Vs JDK's List and Map in terms of 1. time performance and 2. memory consumption
could anyone explain about the time and memory performance of guava?
You are mixing up multiple things.
List
, Set
and Map
are 3 of the foundation interfaces for the Java collection library. Guava's Multiset
and Multimap
, while similar sounding, aren't direct extensions of Set
and Map
.
Multiset
isn't really a Set
(it extends Collection
directly, actually), in that it allows duplicates, but also doesn't (necessarily) satisfy ordering like List
(for this, you can have a LinkedHashSet
, which is a Set
implementation). Multisets in general are often referred to as bags.
Multimap
is a map (but not an extension of the Map
interface) accepting multiple values for the same key.
Also, consider looking at Multiset & Multimap: What's the Point? While this is originally for C++, the accepted answers gives you concrete examples of good use cases where these make senses.
So, performance and memory consumption isn't the primary concern here. The primary concern is whether or not these are the right data-structure for your use case.
Also, interfaces don't really allow you to make any assumptions on memory consumptions (beside from general assumptions on what you'd expect from a list, set or map type), as they only define an API's contract. What you want to look at are the actual implementations for these interfaces, if you want to compare them.