effective java-generic

来源:互联网 发布:网络爱情歌曲大全 编辑:程序博客网 时间:2024/05/22 11:50
As a quick review,
Set<Object> is a parameterized type representing a set that can contain objects of
any type, Set<?> is a wildcard type representing a set that can contain only
objects of some unknown type, and Set is a raw type, which opts out of the
generic type system. The first two are safe and the last is not.


If you can’t eliminate a warning, and you can prove that the code that
provoked the warning is typesafe, then (and only then) suppress the warning
with an @SuppressWarnings("unchecked")annotation.


0 0
原创粉丝点击