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 i
Convert two String arrays to Map in Java
import java.util.HashMap;
public static void main(String[] args){
String[] keys= {"a", "b", "c"};
int[] vals= {1, 2, 3};
HashMap hash= new HashMap();
for(int i= 0; i < keys.length; i++){
hash.put(keys[i], vals[i]);
}
}
Check this LINK for more solutions in different programming languages
Note : The keys should be unique..