// Java Program to count number of employees working in a company (Completed With Garbage Collection) class Employee { private String name ; private int age ; private int ID ; private static int nextId = 1 ; public Employee ( String name , int age ) { this . name = name; this . age = age; this . ID = nextId ++ ; } public void show () { System . out . println ( " \n ID=" + ID + " \n Name=" + name + " \n Age=" + age); } public void showNextId () { System . out . println ( "Next employee id will be=" + nextId); } protected void finalize () { -- nextId; // In this case, // gc will call finalize() // for 2 times for 2 objects. } } c