KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Company


1 import java.util.*;
2
3 public class Company
4     {
5     private Map m_employees;
6     
7     public Company()
8         {
9         m_employees = new HashMap();
10         }
11         
12     public void addEmployee(Employee emp)
13         {
14         m_employees.put(emp.getId(), emp);
15         }
16         
17     public void printEmployees( )
18         {
19         Iterator it = m_employees.values().iterator();
20         Employee emp;
21         
22         while (it.hasNext())
23             {
24             emp = (Employee)it.next();
25             System.out.println(emp.getName());
26             }
27         
28         }
29     }
30
Popular Tags