Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //8.12 Employee.java
- //Static variable used to maintain a count of the number of
- //Employee objects in memory.
- public class Employee
- {
- private String firstName;
- private String lastName;
- private static int count = 0; //number of Employees created
- public Employee1(String first, String last)
- {
- firstName=first;
- lastName=last;
- ++count; //increment static count of employees
- System.out.printf( "Employee constructor: %s %s; count = %d\n",
- firstName, lastName, count);
- }
- public String getFirstName()
- {
- return firstName;
- }
- public String getLastName()
- {
- return lastName;
- }
- public static int getCount()
- {
- return count;
- }
- } //end class Employee
Advertisement
Add Comment
Please, Sign In to add comment