As you can see in this phrase, it is a relatively simple task in Java to convert a collection, such as an ArrayList or HashMap, into a regular array of objects. The ArrayList has a toArray() method that returns an array of objects. Converting a HashMap to an array is slightly different. First, we must get the values stored in the HashMap as an array, using the enTRySet() method. The enTRySet() method returns us the data values as a Java Set. Once we have the Set object, we can call the toArray() method to get an array containing the values that were stored in the HashMap. |