title: Java: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList
body: <p>I'm writing a client for vk.com and got an error.</p>
  
  <p>Im using fragments and i think it caused by fragments.</p>
  
  <p>Process: ru.dennes544.vkapp, PID: 9357
      java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList com.perm.kate.api.Api.getProfiles(java.util.Collection, java.util.Collection, java.lang.String, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
              at ru.dennes544.vkapp.Profile$1.run(Profile.java:89)</p>
  
  <p>few lines of code:</p>
  
  <pre><code>private void loadAccInfo(){
      new Thread(){
          @Override
          public void run(){
              Collection uid = new ArrayList();
              try {
                  uid.add(account.user_id);
                  profiles = api.getProfiles(uid, null, "sex", "Nom", null, null).get(0);
              } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              } catch (KException e) {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>and declaration of getProfiles:</p>
  
  <pre><code>public ArrayList&lt;User&gt; getProfiles(Collection&lt;Long&gt; uids, Collection&lt;String&gt; domains, String fields, String name_case, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
      if (uids == null &amp;&amp; domains == null)
          return null;
      if ((uids != null &amp;&amp; uids.size() == 0) || (domains != null &amp;&amp; domains.size() == 0))
          return null;
      Params params = new Params("users.get");
      if (uids != null &amp;&amp; uids.size() &gt; 0)
          params.put("user_ids",arrayToString(uids));
      if (domains != null &amp;&amp; domains.size() &gt; 0)
          params.put("user_ids",arrayToString(domains));
      params.put("fields",fields);
      params.put("name_case",name_case);
      addCaptchaParams(captcha_key, captcha_sid, params);
      JSONObject root = sendRequest(params);
      JSONArray array=root.optJSONArray("response");
      return User.parseUsers(array);
  }
  </code></pre>