0

So basically what I'm trying to do is add an object to position 0 of an array then add another object and once I add that one I want to make sure that the NEW added object doesn't have the same first or second parameter but I keep getting a null pointer exception if I try to do that and I've been at it for hours and I can't seem to find the issue.

this is the first part of my method

 public boolean hireUndergraduateTA(String firstName, String lastName,
         double hourlySalary) { 

    boolean result=false; 

     /*
    int nextPosition = 1; 
    boolean k = (taList[nextPosition].getTAFirstName()).equals(firstName); 
    boolean j = (taList[nextPosition].getTALastName()).equals(lastName);
      */


    for (int i = 0; i<taList.length; i++){ 
             taList[i] = new TA(firstName, lastName, hourlySalary); 

         if (firstName.equals(null)||
             lastName.equals(null)||
            (hourlySalary<=0)){ 
             taList[i] = null;
             result = false; 
         }
         /*
         if (k || j == true){ 
            taList[nextPosition] = null; 
            result = false; 

         }
         */
         else { 
             result = true; 
             numOfUndergradTAs++;
         }
      }
      return result;
   }

the commented out portions are the ones that are giving me the null pointer exception. I guess my question is this: how do I syntax-tically (word?) tell the commented out portions to not check until there's more than one object in the specific array?

lionbear28
  • 23
  • 8

0 Answers0