title: ArrayList of HashMap elements to Array
body: <p>How can I get an array of elements in a <code>ArrayList</code> of <code>HashMaps</code>? I have an HashMap with url key on it. The value is a url address. Several <code>HashMaps</code> are stored in a <code>ArrayList</code>. What I want is an <code>array</code> with all url strings. I'm not happy with the solution I found because I think it could be extracted from <code>ArrayList</code> with some manipulation.</p>
  
  <pre><code>    // Hashmap for ListView        
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; itemsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      // Creating JSON Parser instance
      JSONParser jParser = new JSONParser();
      jParser.execute(url); 
  
      try {
          JSONObject json = jParser.get();
  
          items = json.getJSONArray(TAG_ITEMS);
          //This is the solution that I want to optimize
          urls = new String[items.length()];
  
          // looping through All items
          for(int i = 0; i &lt; items.length(); i++){
              JSONObject c = items.getJSONObject(i);
  
              // Storing each json item in variable
              String title = c.getString(TAG_TITLE);
              String description = c.getString(TAG_DESCRIPTION);
              String author = c.getString(TAG_AUTHOR);
  
              // Media is another JSONObject
              JSONObject m = c.getJSONObject(TAG_MEDIA);
              String url = m.getString(TAG_URL);
  
              // creating new HashMap
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
              // adding each child node to HashMap key =&gt; value
              map.put(TAG_TITLE, title);
              map.put(TAG_DESCRIPTION, description);
              map.put(TAG_AUTHOR, author);
              map.put(TAG_URL, url);
  
              // Solution
              urls[i] = url;
  
              // adding HashList to ArrayList
              itemsList.add(map);
          }
      } catch (JSONException e) {
          e.printStackTrace();
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
  </code></pre>