Question: I have some confusion about generic programming in java:

If Manager is subclass of Employee,

```
Collection<Manager> managers=new Collection<Manager>;  
Collection<Employee> employees=managers;//why illegal?

```

Why the last statement is illegal?

Since according to illustration in the book CORE JAVA,after
the erasion,`Collection<Manager>` and `Collection<Employee>` are
all converted into raw type `Collection`.

Answer: 
Just imagine your code would be legal. (Let Apple be a subclass of Fruit)

```
Collection<Fruit> apples = { new Apple() };
Collection<Apple> fruit = apples;

fruit.add(new Banana()); // Inserting a banana into a list of apples
                         // Breaks type safety

```
Forgetting about erasure for the moment: If you were allowed to assign a value of type Collection[Manager] to a variable of type Collection[Employee], then when you tried to, say add an Employee to the collection (which the variable name indicates is definitely legal), the addition would fail because what the variable is pointing to is actually a collection of Managers.

Java tries to keep you honest and consistent this way.