title: Exception in thread "Thread-0" java.lang.NullPointerException
body: <p>I have a method in a client server program which is meant to create an instance of a citylist class, which is just an array list of cities...</p>
  
  <p>(This method is in server) </p>
  
  <pre><code>public void listCities() {
      CityList LoadCities = new CityList();
      String CityDetails = LoadCities.cities.toString();
      try {
          dos.writeUTF("These are the cities serviced by the ssystem");
          dos.writeUTF(ServerConstants.CR_LF);
          dos.writeUTF(CityDetails);
      } catch (IOException ex) {
          Logger.getLogger(SocketHandler.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  }
  </code></pre>
  
  <p>The CityList Class is this:</p>
  
  <pre><code>public class CityList {
  
  public ArrayList&lt;City&gt; cities;
      City melbourne = new City("Melbourne");
      City sydney = new City("Sydney");
      City darwin = new City("Darwin");
      City launceston = new City("Launceston");
      City hobart = new City("Hobart");
  
  //default constructor
  public CityList() {
      cities.add(melbourne);
      cities.add(sydney);
      cities.add(darwin);
      cities.add(launceston);
      cities.add(hobart);
  }
  
  
  //other constructor
  public CityList(ArrayList&lt;City&gt; cities) {
      this.cities = cities;
  }
  
  public int size()
  {
      return cities.size();
  }
  
  
  
  }
  </code></pre>
  
  <p>The client exists in a thread... The server calls a socket handler in its own thread class SocketHandler extends Thread 
      class SocketHandler extends Thread </p>
  
  <p>I continually get this error when I try to call that particular method (list cities)</p>
  
  <pre><code>Exception in thread "Thread-0" java.lang.NullPointerException
  at hotelbroker.CityList.&lt;init&gt;(CityList.java:30)
  at hotelbroker.SocketHandler.listCities(MultiEchoServer.java:153)
  at hotelbroker.SocketHandler.run(MultiEchoServer.java:95)
  </code></pre>
  
  <p>I know this is cuz I'm a n00b and I need to call some kind of this instance thingummy I just have no idea...</p>