class Test { public static void main(String[] args) { Employee[] e1 = {new Employee("Aaron", 50), new Employee("Betty", 60)}; Manager m1 = new Manager(e1, "Accounting");
Employee[] e2 = {new Employee("Cathy", 70), new Employee("Dan", 80), new Employee("Eliz", 90)}; Manager m2 = new Manager(m1, e2, "Production");
System.out.println(m2); Employee[] emp = m2.getEmployee(); if (emp != null) for (int k = 0; k < emp.length; k++) System.out.println(" "+emp[k]+" Salary: $"+ emp[k].getSalary()); Manager m = m2.getManager(); System.out.println(" " + m); if (m!= null) { Employee[] emps = m.getEmployee(); if (emps != null) for (int k = 0; k < emps.length; k++) System.out.println(" " + emps[k]+" Salary: $"+ emps[k].getSalary());
} } }
output C:\> java Test Production manager Employee Cathy Salary: $70.0 Employee Dan Salary: $80.0 Employee Eliz Salary: $90.0 Accounting manager Employee Aaron Salary: $50.0 Employee Betty Salary: $60.0
why is the output like this first it should call the accounting manager then it should call the production manager because first we called with manager m1 so say the reason for this please
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Welcome to JavaRanch.
I'm not following your reasoning. First you print m2 -the production mgr-, then the employess, then m2's manager -the accounting mgr-, then that persons employees. Looks fine to me.
What do you mean by
first we called with manager m1
? You're starting with m2, not m1. [ June 15, 2006: Message edited by: Ulf Dittmer ]