Create an array containing the keys in a map
import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] argv) throws Exception { Map map = new HashMap(); Object[] objectArray = map.keySet().toArray(); MyClass[] array = (MyClass[]) map.keySet().toArray(new MyClass[map.keySet().size()]); } } class MyClass { }