Java Reference
In-Depth Information
int size = employees.size();
System.out.println(“The size is now “ + size);
System.out.println(“The capacity is now “
+ employees.capacity());
for(int i = 0; i < size; i++)
{
Employee current = (Employee) employees.elementAt(i);
if(current instanceof Hourly)
{
((Hourly) current).setHoursWorked(40);
}
else if(current instanceof Contractor)
{
((Contractor) current).setDaysWorked(5);
}
current.computePay();
current.mailCheck();
}
}
}
The VectorDemo2 program adds 10 Employee objects to the employees Vec-
tor. The following statement removes employee number 4:
employees.remove(s)
Figure 9.9
Output of the VectorDemo2 program.
Search WWH ::




Custom Search