title: How to add to ArrayList in a For loop
body: <p>I have a sequence of information being randomly generated. I would like to save that information in a variable of some kind so that it can be recalled elsewhere. i <em>think</em> I want to use an ArrayList, but I'm not sure how to add the  information while inside a for loop (which is where it is being created). The code I have is as follows:</p>
  
  <pre><code>public static ArrayList&lt;String&gt; phoneList
  
  public static void main(String[] args){
  
      Random randomNumber = new Random();
      int howMany = randomNumber.nextInt(11);;
      String holding; 
  
      for (int i=0; i &lt; howMany; i++){
          int itemRandNum = randomNumber.nextInt(11);//for all Item Categories
          int priceRandNum = randomNumber.nextInt(11);//Prices for all categories
          holding = phones[itemRandNum]+" $"+ priceOfPhones[priceRandNum]; 
  
          //System.out.println(holding);
          phoneList.add("holding"); //here is where I would like to add the information 
                                  //contained in "holding" to the "phoneList" ArrayList.
  
      }
  
      System.out.println(phoneList);
  }
  </code></pre>
  
  <p>I am getting a NullPointerException. If an ArrayList is not the best thing to use here, what would be?</p>
  
  <p>Any help you can give is appreciated. </p>