The*_*ect 7 java generics intellij-idea
我是IntelliJ IDEA的新手.我曾经使用过Eclipse.
默认情况下,IntelliJ不会要求为Java Generics Type提供参数类型.
// Following code doesn't give any warning
List list = null;
// I want to make IntelliJ ask me to specify type parameter (say Long)
List<Long> list = null; // i.e If I want a List of Long
Run Code Online (Sandbox Code Playgroud)
如何设置IntelliJ以便它在使用泛型java类型时让我提供泛型类型参数?
如果重要的话,我正在使用JDK 8.
在Project Structure菜单中的 下Project,检查语言级别设置。6.0当您在菱形块中丢失标识符时,将其设置为将导致 IDE 给您一个错误。
将其设置为 7.0 或更高将抑制它。
基于进一步交流的添加:
在此示例File -> Settings -> Inspections -> General中,如果Unchecked warning选中了该框,当您运行时Analyze -> Inspect code,它会报告General -> Unchecked warnings“未检查调用 add(E) 作为原始类型 'java.util.List' 的成员”下注明的条件。如果您明确声明 List 的泛型类型,则此警告将不会出现在报告中。
| 归档时间: |
|
| 查看次数: |
8697 次 |
| 最近记录: |