I have below code snippet and this works fine. Shouldn't it throw compile time error because I have defined `c` as `ArrayList` which will contain `String` object but I am adding `Integer` object. So why it did not throw compile time/Run time error?

```
Collection c = new ArrayList<String>();
c.add(123);

```

I know below will throw compile time error but why not above. Whats the logical difference between both these code snippet?

```
 Collection<String>() c = new ArrayList();
 c.add(123);

```