title: JAVA: Hashmap - return arraylist of strings
body: <p>I'm trying to write a method that will return an <em>ArrayList</em> of Strings from my <em>HashMap</em>.</p>
  
  <p>Currently I have a <em>HashMap</em> that contains a <em>String</em> as the identifier (key?), and a <em>List</em> of type <em>String</em> that holds all the values associated with it. The program is meant to mimic a train/subway navigation tool, so the first <em>String</em> is the station name, and the arraylist is a series of Strings showing all the connected stations. </p>
  
  <p>Here is what I have so far, but it won't currently compile. There are several other methods which I know are working, so I've just put the final one which I'm having difficulty with (<code>getConnections</code>). </p>
  
  <p>I'm very much a novice at this, so if someone could point out where I've gone wrong I'd really appreciate it.</p>
  
  <pre><code>public class MyNetwork implements Network {
      Map&lt;String, List&lt;String&gt;&gt; stations = new HashMap&lt;&gt;();
  
      @Override
      public String[] getConnections(String fromStation) {
  
      /**
       * Get a list of all stations directly connected to a given station.
       *
       * @pre fromStation has been added to the network by the method
       * addStation.
       * @param fromStation
       * @return A list of all the stations to which there is a direct
       * connection from fromStation.
       */
      ArrayList&lt;String&gt; Connections = new ArrayList&lt;&gt;();
      Set&lt;String&gt; keys = stations.keySet();
  
      for (String k : keys) {
          String keyValue;
          keyValue = (stations.get(fromStation));
      }
  
      return fromStation;
  }
  </code></pre>