Mxolisi Veco wrote:
What can I add to the statement such that I will not get the uncheck warning ?
There's no clean solution, you have to suppress the warning, as David has said.
The reason is that at runtime, you have no information on the type parameters, so no magic will save you. You could improve this somewhat by turning y into HashMap<Integer,
String> though, so you'll be type-safe at least from that point on (if y really is that type - it is, in your case, but if it's something you've restored from serialised form, or got from some other piece of code you have no control over, and the Object points to a HashMap where the key and the value are not Integer and String, you'll run into ClassCastExceptions, or, even worse, hard to find bugs - Map.get, containsKey, containsValue take Object as parameter so no cast/typecheck will be performed even at runtime, get will just return null, contains* false).