I'm at the end of writing some code that will manage a 'dummy' train/subway network of stations. I have implemented it using a Map of type Map (String), (List)(String). The final method (the one I'm now struggling with) Should return all the 'stations' that have been added to the network, without duplicates. I'm trying to just get the values to return at the moment, however any advice on both issues would be appreciated. I've included below how I've set up the map, and the method in question. Ideally i'd like these values to be returned as an array, but the compiler seems to be taking some issue with my syntax. Thanks again!
public class MyNetwork implements Network {
Map<String, List<String>> stations = new HashMap<>();
@Override
public String[] getStations() {
/**
* Get all stations in the network.
* @return An array containing all the stations in the network, with no
* duplicates.
*/
return stations.toArray(new String[0]);
}