title: Why is my name field null after running setName and getName?
body: <p>I am working on program and I got everything to work, but I can't pass a part of the test my professor gives us to test our programs. It tell me my name field is null after running setName and getName with null data. Make sure mutator sets name to empty string on null data. Make sure accessor isn't incorrectly returning null values. It doesn't say if anything is wrong with my setLicense and getLicense, I have a feeling it will have the same issue also since they are so similar. I don't think this question has been asked before, but it has sorry.</p>
  
  <pre><code>public class Pilot
  {
  private String name;
  private String license;
  
  /** Parameterized constructor for Pilot.
   * 
   * Sets the fields using the parameter values.
   */
  public Pilot(String name, String license)
  {
      this.name = name;
      this.license = license;
  }  
  
  /** No-arg Constructor for Pilot.
   * 
   * Sets the fields name and license to blank instead of them being null. 
   * This prevents the program from crashing if another method is called 
   * before the name and license objects' fields are made to reference 
   * the String objects.
   */
  public Pilot()
  {
      name = "";
      license = "";
  }    
  
  //I have clue if this getLength() is needed. I was just trying 
  //code from my textbook
  public int getLength()
  {
      int len = 0;
  
      if (name != null)
          len += name.length();
  
      if (license != null)
          len += license.length();   
  
      return len;
  
  }    
  
  /** Mutator for name.
   * 
   * @param {String} name - Somebody's name.
   */
  public void setName(String name)
  {
      this.name = name;
  }
  
  /** Mutator for license.
   * 
   * @param {String} license - Somebody's license.
   */
  public void setLicense(String license)
  {
      this.license = license;
  }
  
  /** Accessor for name.
   * 
   * @return Returns name
   */
  public String getName()
  {
      return name;
  }
  
  /** Accessor for license.
   * 
   * @return Returns license
   */
  public String getLicense()
  {
      return license;
  }    
  
  /** copy() method for Pilot class.
   * 
   * @return Returns p A new object that is an object of Pilot 
   * @param {Object[]} - copy method of Pilot
   */    
  public Pilot copy()
  {
      // Create a new Pilot object and initialize it
      // with the same data held by the calling object.
      Pilot pilot = new Pilot(name, license);
  
      // Return a reference to the new object.
      return pilot; 
  
      // book code, may need as reference
      // Pilot copyObject = new Pilot(name, license);
      // return copyObject;        
  }
  
  /**
   * toString() method for Pilot class.
   * 
   * @return Returns String.format which determines the print format of the 
   * pilot later in the class.
   * @param {String} - toString() method 
   */    
  public String toString()
  {
      return String.format("%s %1s %1s %1s %1s", 
                           "Name:",name, "-", 
                           "License:", license);
  }    
  
  /** 
   * equals() method for Pilot class.
   * 
   * @return Returns status
   * @param {Object[]} pilot 
   */    
  public boolean equals(Pilot pilot)
  {   
      boolean status;
      // Determine whether this object(pilot) name and
      // license fields are equal to Pilot's 
      // name and license fields.
      if (this.name.equals(pilot.name) &amp;&amp;
          this.license.equals(pilot.license))
          status = true;  // Yes, the objects are equal.
      else
          status = false; // No, the objects are not equal.
  
      // Return the value in status.
      return status;
  }
  
  /**
   * The main method.
   * 
   * @param {args} Runs the main method. A new Pilot object is created(pilot) 
   * with values for the name and license Strings. The new Pilot object(pilot)
   * is then printed as "Name: Tom - License: 12345-2" based off the 
   * formatting in the toString() method.
   */    
  public static void main(String[] args)
  {
      Pilot pilot = new Pilot("Tom", "12345-2");  
      System.out.println(pilot);
  }
  </code></pre>
  
  <p>}</p>