I have two string arrays keys and values
String[] keys = {a,b,c,d};
String[] values = {1,2,3,4};
What is the fastest way to convert them into a map? I know we can iterate through them. But, is there any utility present?
Faster than this?
Map<String,String> map = new HashMap<>();
if(keys.length == values.length){
for(int index = 0; index < keys.length; index++){
map.put(keys[index], values[index]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With