简体   繁体   English

如何抑制未经检查的课堂警告

[英]How to suppress unchecked class warning

how to I pass HashMap<String, String>.class in Gson builder for supperss "unchecked warning"? 如何在Gson生成器中传递HashMap<String, String>.class以获取晚饭“未经检查的警告”?

HashMap<String, String> manifest = 
    Gson().fromJson(stringBuilder.toString(), HashMap.class);

@SuppressWarnings("unchecked")标记您的方法

Please add @SuppressWarnings("unchecked") above your Hashmap reference. 请在Hashmap参考上方添加@SuppressWarnings("unchecked") This will only ignore the next statement to it instead of whole method. 这只会忽略下一条语句,而不是整个方法。

@SuppressWarnings("unchecked") 

HashMap<String, String> manifest = 
        Gson().fromJson(stringBuilder.toString(), HashMap.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用泛型而不是声明来抑制未检查的类型转换警告? - How to suppress unchecked typecast warning with generics not at declaration? 为什么抑制这种未经检查的警告是安全的? - Why is it safe to suppress this unchecked warning? 如何适当地泛化此类,以避免未经检查的警告? - How to properly generify this class to avoid unchecked warning? Java - 使用WatchEvent抑制未经检查的强制转换警告是否安全? - Java - Is it safe to suppress unchecked cast warning with WatchEvent? 课堂上未经检查的警告<Collection> - unchecked warning on Class<Collection> 如何解决类型安全警告从集合到列表的未经检查的强制转换 <File> 没有抑制注释的Java 6 - How to address Type safety warning Unchecked cast from Collection to List<File> Java 6 without suppress annotation Java:通用类型转换,如何解决此问题,以免抑制未经检查的警告 - Java: Generic type casting, how can I fix this so I don't suppress the unchecked warning 如何使用Gradle抑制“警告:忽略匿名内部类的InnerClasses属性”? - How to suppress “warning: Ignoring InnerClasses attribute for an anonymous inner class” with Gradle? 如何解决这个未经检查的分配警告? - How to fix this unchecked assignment warning? 编译器警告类使用未经检查或不安全的操作 - Compiler Warning class uses unchecked or unsafe operations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM