Ben*_*Ben 16
您可以在此处找到答案:使用JSON Iterator键入安全警告
Iterator<?> it = schemaJSON.getJSONObject("body").keys();
while(it.hasNext())
{
String next = (String) it.next();
...
Run Code Online (Sandbox Code Playgroud)
如果您只想删除警告,
"Iterator类型的表达式需要未经检查的转换以符合Iterator"
然后这样做,
Iterator<String> it = (Iterator<String>)schemaJSON.getJSONObject("body").keys();
Run Code Online (Sandbox Code Playgroud)
但这会导致新的警告,但您的旧警告会被删除.
Type safety: Unchecked cast from Iterator to Iterator<String>
要删除所有警告,
Iterator<?> it = schemaJSON.getJSONObject("body").keys();
while(it.hasNext())
{
String nextElement = (String) it.next();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8461 次 |
| 最近记录: |