title: Add value to array in Android
body: <p>I have class named as <code>login</code> (without encapsulate fields, I just want to make it simple)</p>
  
  <pre><code>public class login
  {
      String username;
      String password;
  
      public login(String username, String password)
      {
          this.username = username;
          this.password = password;
      }
  }
  </code></pre>
  
  <p>DisplayList.java</p>
  
  <pre><code>public class DisplayList extends ListActivity
  {
      login[] values;
  
      protected void onCreate(Bundle savedInstanceState)
      {
          String username, password;
          int count = 0;
          while (count &lt; somelength)
          {
              username = somestring;
              password = somestring;
  
              values[count] = new login(username, password);
  
              //if I Toast it
              //Toast.makeText(this, username + " . " + password, Toast.LENGTH_SHORT).show();
  
              count++;
          }
  
          login_adapter = new login_adapter(this, values);
          setListAdapter(login_adapter);
      }
  }
  </code></pre>
  
  <p>I want to pass values (<b>login[]values</b>) to login_adapter (<b>class login_adapter extends ArrayAdapter</b>)
  <br><BR>
  but I always come with NullPointerException on "<b>values[count] = new login(username, password);</b>"
  <br><br>if I Toast it "<b>Toast.makeText(this, username + " . " + password, Toast.LENGTH_SHORT).show();</b>" the Toast come with all values.</p>