[英]Warning: [unchecked] unchecked cast for Map
I found the following exception.我发现了以下异常。 How do I resolve that warning?
我该如何解决该警告?
Exception:例外:
warning: [unchecked] unchecked cast
Map<String, Object> map = (Map<String, Object>) obj;
required: Map<String,Object>
found: Object
Code:代码:
List<?> results = response.getResults();
for (Object result : results) {
Map<String, Object> map = (Map<String, Object>) result;
You can't.你不能。 Casting an
Object
to a Map
will always give you this warning.将
Object
转换为Map
将始终给您此警告。
The only way to fix it is to have a more specific type than Object
in the first place.解决它的唯一方法是首先使用比
Object
更具体的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.