I have created one hashmap. All I need to do is get the keys from the hashmap and store in a String[] array.
This is what I was doing but it's not correct.
HashMap<String, String> columnHeaders = new HashMap<String, String>();
columnHeaders.put("Id", "101");
columnHeaders.put("First Name","AAA");
columnHeaders.put("Last Name","BBB");
columnHeaders.put("Country","CCC");
columnHeaders.put("City","DDD");
columnHeaders.put("State","EEE");
columnHeaders.put("Province","FFF");
}
String[] keyHeaders=null;
for(Map.Entry<String, String> param : columnHeaders.entrySet()){
String key = param.getKey();
keyHeaders = key.split(";");
Arrays.toString(keyHeaders);
}
I kept the String[] global because I need pass it to a for loop.
Could please someone help me with this?
;? If you can use the keys as they are, just useString[] keyHeaders = columnHeaders.keySet().toArray(new String[0]);.String[] keys = columnHeaders.keySet().toArray(new String[0]);