You need to sign in to do that
Don't have an account?
Ashu sharma 38
How to count the size of two maps
Hi,
As I have two maps
Map 1---Program code and ContactId
Map 2---Program Code and Program term.
Now how to get the count of uniques program code from these two map.
Any idea.
As I have two maps
Map 1---Program code and ContactId
Map 2---Program Code and Program term.
Now how to get the count of uniques program code from these two map.
Any idea.
Eg:
Set<String> setUniqueCode = new Set<String>();
setUniqueCode.addAll(map1.keySet());
setUniqueCode.addAll(map2.keySet());
setUniqueCode will now contain all the unique codes. No dupes.
If so, duplicate keys are not allowed on a map so that you might set the ContactId from your contact SObject as the key in your first map, and for the second one, another key where it can be used as unique as well.
Otherwise, you might loop through those maps and add both in a unique set and then pick up the size.
Okay...thanks
I am trying the steps.
A map consists of key-value pairs where keys uniquely can be mapped to one or many values, so the keyset itself is unique (without any duplicates).
To get the count of map, you can use the size() function which will return you the number of key-value pairs in the map as below:
Interger count = map.size();
Thanks,
Adheesh