# Java: how to convert HashMap<String, Object> to array

Please mention  a shortest and simplest way so that i can convert a HashMap<String, Object> to an array?

hashMap.keySet().toArray(); // returns an array of keys
hashMap.values().toArray(); // returns an array of values

Should be noted that the ordering of both arrays may not be the same, See oxbow_lakes answer for a better approach for iteration when the pair key/values are needed.