February 2014
Beginner
1248 pages
62h 25m
English
Our next program declares two classes—Employee (Fig. 8.12) and EmployeeTest (Fig. 8.13). Class Employee declares private static variable count (Fig. 8.12, line 7) and public static method getCount (lines 36–39). The static variable count maintains a count of the number of objects of class Employee that have been created so far. This class variable is initialized to zero in line 7. If a static variable is not initialized, the compiler assigns it a default value—in this case 0, the default value for type int.
Read now
Unlock full access