Adding the results to an arraylist
<p>I am facing some difficulties while assigning the values in an array list. My code is :</p>

<pre><code>while (answer.hasMore()) {
  SearchResult rslt = (SearchResult)answer.next();
  Attributes attrs = rslt.getAttributes();
  System.out.println();
  if (attrs.get("department") != null &amp;&amp; attrs.get("telephonenumber") != null) {
      System.out.println(attrs.get("department") + " " + attrs.get("name") + " " +
                         attrs.get("Description") + " " + attrs.get("mail") + " " +
                         attrs.get("telephonenumber")+
                         attrs.get("samaccountname") + attrs.get("samaccountname") );
}
</code></pre>

<p>I want to assign the values of <code>attrs.get("department") + attrs.get("description")+ attrs.get("name")+attrs.get("mail")</code> each one to an array list.</p>

<p>I tried to define at the beginning:</p>

<pre><code>String[] name = new String[100];
</code></pre>

<p>and in the while loop i tried to read the name attribute, I tried to do:</p>

<pre><code>name = attrs.get("name");
</code></pre>

<p>But it did not work. Can anyone help.</p>
