Creating a new instance of a class from another class
<p>So I'm stuck on some homework trying to create an instance of the Employee class from my class called records.</p>

<pre><code>public class Employee implements Comparable&lt;Employee&gt;

{
/* instance variables */
private String Name;
private String employeeNumber;


/**
 * Constructor for Employee
 */
public Employee(String employNum)
{
   super();
   this.employeeNumber = employNum;             
}
</code></pre>

<p>Next I need to create a Record class that will create a HashSet of Employees details, this is where I need help.</p>

<pre><code>public class Records
{
   private HashSet employeeSet;

   public Records()
   {
      Set&lt;Employee&gt; employeeSet = new HashSet&lt;Employee&gt;();
   }
</code></pre>

<p>Then I want it to have a method for adding a new employee and then putting their records in the set.</p>

<pre><code>   public  enrollEmployee(String num)
   {
      Employee newEmp = new Employee(num);
      employeeSet.add(newEmp);
   }
}
</code></pre>

<p>I can't get that last bit to create a new employee, it doesn't come out with an error and it compiles correctly. Just no new employee. 
*Adding the employeeSet.add(newEmp); caused a compiler warning and that method won't run due to a NullPointerException, probably because the employee isn't actually created.</p>

<p>For more info, when I create an employee the name should come out as "null" if only an employee number is entered but I still need to store that information.</p>

<p>Edited to update information. There is more detail for the Employee class which I have left out, I'm only supposed to be creating the Records class.</p>

<p>Last update, thank you for the help. After reading the replies this is what I got to work for me.</p>

<pre><code>   public class Records
{
   private Set&lt;Employee&gt; employeeSet = new HashSet&lt;Employee&gt;();

   public Records()
   {

   }

   public void enrollEmployee(String num)
   {
      Employee newEmp = new Employee(num);
      employeeSet.add(newEmp);
   }
}
</code></pre>