title: Attemptto invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference
body: <p>hey Guys I try to get data in json format and than i show them in the spinner.
  I stuck in one problem can you plz help me.
  here is my code.</p>
  
  <pre><code>public class MainActivity extends Activity {
      Spinner selectcityspinner, selectareaspinner;
      ArrayList&lt;city&gt; citylist;
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          return super.onCreateOptionsMenu(menu);
      }
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          selectcityspinner = (Spinner)findViewById(R.id.selectcityspin);
          selectareaspinner = (Spinner) findViewById(R.id.selectareaspin);
          List&lt;city&gt; citylist = new ArrayList&lt;&gt;();
          new cityAsynTask().execute("http://bund.webs.com/citylist.txt");
  
          /*ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt; (MainActivity.this,android.R.layout.simple_spinner_item,citylist);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          selectcityspinner.setAdapter(adapter);
          selectcityspinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  Toast.makeText(getBaseContext(),parent.getItemAtPosition(position) + " selected",Toast.LENGTH_LONG).show();
  
                  String Country = String.valueOf(parent.getItemAtPosition(position));
  
                  if (Country.contentEquals("Ahmedabad"))
                  {
                      List&lt;String&gt; AreaList = new ArrayList&lt;String&gt;();
                      AreaList.add("Ghatlodia");
                      AreaList.add("Chandlodia");
                      AreaList.add("Others");
                      ArrayAdapter&lt;String&gt; adapter1 = new ArrayAdapter&lt;String&gt; (MainActivity.this,android.R.layout.simple_spinner_item,AreaList);
                      adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                      adapter1.notifyDataSetChanged();
                      selectareaspinner.setAdapter(adapter1);
                  }
  
  
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
              }
          });*/
  
      }
      public class cityAsynTask extends AsyncTask&lt;String,Void,Boolean&gt;
      {
  
          @Override
          protected Boolean doInBackground(String... params) {
  
              try {
                  HttpClient client = new DefaultHttpClient();
                  HttpPost post = new HttpPost(params[0]);
                  HttpResponse response = client.execute(post);
                  int status = response.getStatusLine().getStatusCode();
                  if (status == 200) {
                      HttpEntity entity = response.getEntity();
                      String data = EntityUtils.toString(entity);
                      JSONObject jobjcity = new JSONObject(data);
                      JSONArray jarray = jobjcity.getJSONArray("actors");
                      for (int i = 0;i &lt; jarray.length();i++){
                          city city = new city();
                          JSONObject jrealobject = jarray.getJSONObject(i);
                          city.setCity(jrealobject.getString("name"));
                          citylist.add(city);
  
                      }
                      return true;
                  }
  
              } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
  
              return false;
          }
  
          @Override
          protected void onPostExecute(Boolean aBoolean) {
              super.onPostExecute(aBoolean);
              if(aBoolean == false){
                  Toast.makeText(MainActivity.this,"data isnot recieved",Toast.LENGTH_SHORT).show();
              }
  
          }
      }
  
  }
  </code></pre>
  
  <p>city.java</p>
  
  <pre><code>public class city {
      private String city;
  
      public city(String city) {
          this.city = city;
      }
  
      public city() {
  
      }
  
      public String getCity() {
  
          return city;
      }
  
      public void setCity(String city) {
          this.city = city;
      }
  }
  </code></pre>
  
  <p>Here is my error</p>
  
  <pre><code>02-28 02:12:44.044 2863-2880/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                   Process: com.example.bhaumik.myparsesignup, PID: 2863
                                                   java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                       at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                       at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                       at java.lang.Thread.run(Thread.java:818)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference
                                                       at com.example.bhaumik.myparsesignup.MainActivity$cityAsynTask.doInBackground(MainActivity.java:115)
                                                       at com.example.bhaumik.myparsesignup.MainActivity$cityAsynTask.doInBackground(MainActivity.java:95)
                                                       at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                       at java.lang.Thread.run(Thread.java:818) 
  </code></pre>
  
  <p>Can you guys help me.???
  It really appreciated.</p>