title: java.lang.NullPointerException in netbeans
body: <p>i'm writing a bit of code and i keep getting this error, it's to do with where i call network.addstation</p>
  
  <p>here's the code, there are other methods in the network method but i thought i'd just show one, but it appears when you call any method. any help would be much appreaciated. thanks.</p>
  
  <pre><code>public class MyNetworkReader implements NetworkReader {
  
      Network network = null;
  
      @Override
      public Network read(InputStream stream) {
          Scanner scan = null;
          scan = new Scanner(stream);
          while (scan.hasNext()) {
              String fromStation = scan.next();
              if (!fromStation.equalsIgnoreCase("connection:")) ;
              network.addStation(fromStation)
              System.out.println(fromStation);
          }
      }
  
      return network;
  }
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.HashSet;
  
  public class MyNetwork implements Network {
  
  
      HashMap&lt;String, ArrayList&gt; stations = new HashMap&lt;String, ArrayList&gt;();
  
  
      public void addStation(String station) {
          stations.put(station, null);
      }
  }
  </code></pre>