title: My JUNIT tests is showing a java null pointer exception
body: <p>My class is as follows:</p>
  
  <pre><code>package Productions;
  
  import java.util.Vector;
  
  public class SetOfUsers extends Vector&lt;User&gt; {
      private static SetOfUsers register =  null;
  
      public SetOfUsers(){
          super();
      }
  
      public static SetOfUsers getInstance(){
          if (register == null) { 
              register = new SetOfUsers(); 
          }
          return register;    
      }
  
      public void addUser(User aUser){
          super.add(aUser);
      }
  
      public User findUserByName(String name){
         for(int i = 0; i &lt; size(); i++){
             User user = elementAt(i); 
             if(user.getName().equals(name)){
                 return user;
             }
         }
         return null;
      }
  }
  </code></pre>
  
  <p>Here is my user class</p>
  
  <pre><code>package Productions;
  
  public class User {
      private final String name;
      private final String password;
      private String projectName;
      private String type;
  
  
      public User(String name, String password,String type){
       this.name = name;
       this.password = password;
       this.type = type; //type of user
  
      }
  
  
  
      public boolean checkPassword(String pass)
      {
          if(password.equals(pass))
              return true;
               else
              return false;
  
      }
      public String getName(){
          return name;
      }
      public String getPassword(){
          return password;
      }
      public String getType(){
          return type;
      }
      public void allocateTask(){
  
      }
      public void removeTask(){
  
      }
  
  
      @Override
      public String toString() {
          return "Staff Name: " + this.getName() +
                 ", Staff Pass: " + this.getPassword();
      }
  
  }
  </code></pre>
  
  <p>Above is the class I am testing, it holds a <code>setOfUser</code> names</p>
  
  <pre><code>public void testFindUserByName() {
      String name = "Bob";
      SetOfUsers instance = new SetOfUsers();
      // User expResult = null;
      //User result = instance.findUserByName(name);
      //assertEquals(expResult, result);
      User result;
      instance.add(result);
      // User result = instance.findUserByName(name);
  
      //then
      assertEquals("Bob", result.getName());
  }
  </code></pre>
  
  <p>When I run the test above I am getting a java null pointer exception, I don't understand this, it should pass since I am expecting the name <code>Bob</code>.</p>