Eclipse gives me the warning (in the title) using just the following code in a working project with nothing in it but a dummy class and a main method:
List a
You have declared List a
without the type parameter. This is why eclipse is complaining about type safety, as you could add objects of any type to that list.
If you look at the ArrayList api and take a look at the class declaration, you see it is declared like this:
public class ArrayList<E>
Substitute E with any class you wish.
With List<Integer> b
you have explicitly told the compiler that the list is to hold instances of Integer
objects only, and the compiler can verify this, thus giving you type safety.