When I run this from the CMD first line compiles with warnings ,second compiles without (although they both produce warnings on eclipse).I am very confused because the first declaration of ArrayList can only take Strings ,but second one can take any type of object which will make a mess at runtime so shouldn't it be the other way round? Could you please explain to me this issue because I'm so confused

and please correct me if I'm wrong.