What is the [practical] difference between casting at line 1 & line 2 here, considering Java 6 :
if (obj instanceof HashMap) {
HashMap meta = (HashMap) obj; // line 1, raw-type warnings
// vs
HashMap<?, ?> meta = (HashMap<?, ?>) obj; // line 2, no warnings
// ..
}
Why would someone go for line 2 (no warnings, type-safe), but seems that casted map can not be used in a meaningful way (i.e., put()/get()
) ?