开发者

not able to access the "length" attribute of an array

I made a Manager class which inherits from an employee class... I am facing problems while i am trying to access the length attribute of the array "managedEmployee" of the type "Employee"(Parent class)..

Could anybody tell me the reason for me not being able to access the length attribute of the nanagedEpployee array ????????

Thanks..

public class Manager extends Employee {

   int index = 0;
   private Employee[] managedEmployee = new Employee[10];

   public void inputManagedEmployee(Employee e) {

      if (e == null) {

         System.out.println("invalid Employee");

      } else {
         for (int x = 0; x < managedEmployee.length; x++) {

            managedEmployee[index] = e;
            index++;
         }

      }
   }

   public void displayManagerInfo() {

      System.out.println("The name of the  candidate is :" + getName());
      System.out.println("The Id of the candidate is:" +开发者_Go百科 getID());
      System.out.println("The level of the candidate is :" + getLevel());
      System.out.println("the Title of the candidate is :" + getTitle());

      for (int x = 0; x <= index; x++) {
         if (managedEmployee[x] != null) {
            System.out.println("The name of the managed candidate is :"
                  + managedEmployee[x].getName());

         }
      }

   }
}


managedEmployee.lenght is misspelled. Should be managedEmployee.length

I'm also guessing that inside your for loop, where it says managedEmployee[index]=e; that is should be managedEmployee[x]=e;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜