title: Array Cannot Be Resolved To a Variable - Java
body: <p>I have an employee class:</p>
  
  <pre><code>public abstract class Employee {
  
  private String firstName;
  private String lastName;
  private int joinYear, joinMonth, joinDay;
  LocalDate startDate;
  static int idCounter=0;
  private double employeeId;
  private double numEmployees;
  Employee[] employeeArray = new Employee[10];
  private double monthlyEarnings;
  // constructor
  public Employee(String first, String last, int year, int month, int day) {
      firstName = first;
      lastName = last;
      joinYear=year;
      joinMonth=month;
      joinDay=day;
      startDate= new LocalDate(joinYear, joinMonth, joinDay);
      this.monthlyEarnings=0;
      this.setEmployeeId(idCounter);
      employeeArray[idCounter]=this;
      idCounter++;
      numEmployees++;
  }
  }
  </code></pre>
  
  <p>As you can see above, in the constructor, when an employee object is created, it is added to employeeArray: <code>employeeArray[idCounter]=this;</code></p>
  
  <p>Then when I try to access members of the array in my main method I get the error "employeeArray Cannot Be Resolved To a Variable"</p>
  
  <pre><code>public class Test {
  
  // test Employee hierarchy
  public static void main(String args[]) {
  Employee Employee1 = new Employee("John", "Smith", 1997, 8, 20);
  Employee Employee2 = new Employee("Bob", "Oak", 1999, 6, 20);
  
  
  System.out.println(employeeArray[1]); //error here
  }
  }
  </code></pre>