I see no reason why Eclipse produces yellow squiggly lines(warning) underneath the line of code where Im creating a new ArrayList inside method m1(). When I cannot add a non-String object to the Collection c anyways, why does the IDE wants a <> right next to new ArrayList? At execution time, they are type erased also so trying to understand if it really means anything.
import java.util.ArrayList;
import java.util.Collection;
public class Main {
public static void main(String[] args) {
m1();
}
private static Collection<String> m1() {
Collection<String> c = new ArrayList();//gives typesafety warning for missing <>
c.add("A");
c.add("B");
c.add(1); // does not let me add a non-String type anyways
return c;
}
}