unchecked

What is SuppressWarnings (“unchecked”) in Java?

你。 提交于 2019-11-25 23:38:58
问题 Sometime when looking through code, I see many methods specify an annotation: @SuppressWarnings(\"unchecked\") What does this mean? 回答1: Sometimes Java generics just doesn't let you do what you want to, and you need to effectively tell the compiler that what you're doing really will be legal at execution time. I usually find this a pain when I'm mocking a generic interface, but there are other examples too. It's usually worth trying to work out a way of avoiding the warning rather than