Type safety: Unchecked cast

In my spring application context file, I have something like: <util:map id=”someMap” map-class=”java.util.HashMap” key-type=”java.lang.String” value-type=”java.lang.String”> <entry key=”some_key” value=”some value” /> <entry key=”some_key_2″ value=”some value” /> </util:map> In java class, the implementation looks like: private Map<String, String> someMap = new HashMap<String, String>(); someMap = (HashMap<String, String>)getApplicationContext().getBean(“someMap”); In Eclipse, I see a warning that says: Type safety: … Read more

What is SuppressWarnings (“unchecked”) in Java?

Sometime when looking through code, I see many methods specify an annotation: @SuppressWarnings(“unchecked”) What does this mean? 1Best Answer 11 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 … Read more