title: How to fix this NullPointerException?
body: <pre><code>package blurbProject;
  import java.util.Random;
  import java.util.Scanner;
  
  public class BlurbMaker
  {
  Random generator = new Random(); //"Random" number generator for the Whatzits
  
  public BlurbMaker()//constructor
  {
      generator = null;
  }//close constructor
  
  public BlurbMaker(Random iniGenerator)//initialize constructor
  {
      generator = iniGenerator;
  }//close initialization
  
  private String getWhoozitYs(){
      StringBuffer sb = new StringBuffer();
      boolean stop = generator.nextBoolean(); //NullPointerException here
      if(stop == true)
      {
          sb.append("y");
          getWhoozitYs();
      }
      return sb.toString();
  }
  
  private String getWhozit()
  {
      StringBuffer sb = new StringBuffer();
      sb.append("x");
      sb.append(getWhoozitYs()); //NullPointerException here
      return sb.toString();
  }
  
  private String getWhatzit()
  {
      StringBuffer sb = new StringBuffer();
      sb.append("q");
      boolean stop = generator.nextBoolean();
      if(stop == true)
      {
          sb.append("z");
      }
      else
      {
          sb.append("d");
      }
      sb.append(getWhozit()); //NullPointerException here
      return sb.toString();
  }
  
  private String getMultipleWhatzits()
  {
      StringBuffer sb = new StringBuffer();
      sb.append(getWhatzit());
      boolean stop = generator.nextBoolean();
      if(stop == true)
      {
          sb.append(getWhatzit());
      }
      else
      {
          sb.append("");
      }
      return sb.toString();
  }
  
  public String generateBlurb()
  {
      StringBuffer sb = new StringBuffer();
      sb.append(getWhozit());
      sb.append(getMultipleWhatzits());
  
      return sb.toString();
  }
  
  public static void main(String[] args)
  {
      BlurbMaker blurbmaker = new BlurbMaker();
  
      Scanner scanner = new Scanner(System.in);
      System.out.print("How many blurbs would you like? ");
  
      int blurbNumber = scanner.nextInt();
  
      if(blurbNumber &gt; 0)
          for(int i = 0; i &lt; blurbNumber; i++){
              System.out.println("Blurb: " + blurbmaker.generateBlurb());
                              //NullPointerException on line above
          }
      else
          System.out.println("My work here is done.");
  
      scanner.close();
  }//close main
  
  }//close class
  </code></pre>
  
  <p>I'm working on a project for a programming class and after attempting to run this program I'm getting NullPointerExceptions on the four lines listed in the code here. I know a NullPointerException comes from trying to access something that's null, but I'm not sure of how to fix it.</p>