我如何摆脱“未经检查的演员”警告?

时间:2011-10-05 22:41:22

标签: java android

Map<String,?> one = (Map<String,?>) parent.getAdapter().getItem(position);

Type safety: Unchecked cast from Object to Map<String,?>

使用上面的代码行我得到了未经检查的强制警告。对我来说,获得相同结果但减轻警告的最佳方式是什么?

1 个答案:

答案 0 :(得分:2)

将此注释添加到方法中:

@SuppressWarnings("unchecked") // Object to Map.

一定要对它进行评论 - 在很大的方法中它可能并不明显。