import java.util.ArrayList; /** * The simplest possible example of the effect of generic * erasure in Java. Below we have two ArrayLists that are certainly * different. The compile will not let yo do li = fi * But at run time the two classes are the same!! * */ public class Erasure { public static void main(String[] args) { ArrayList li = new ArrayList(); ArrayList lf = new ArrayList(); //li = fi; // Not allowed if (li.getClass() == lf.getClass()) { // evaluates to true System.out.println("Equal"); System.out.println(li.getClass() + " " + lf.getClass()); } } }