J2EEScan
J2EEScan copied to clipboard
about generics
In this project;
why use "List<IScanIssue> issues = new ArrayList<>()
";
when I take it in Elipse ,this will come a error; why not use "List<IScanIssue> issues = new ArrayList<IScanIssue>()
" or "List<IScanIssue> issues = new ArrayList()
"
My eclipse's verison is 10.0 and java version is 1.7.x
Disclaimer: I'm not the maintainer or author of the project
This is called Type Inference for Generic Instance Creation or informally diamond operator. (<>
looks like a diamond, doesn't it?) It was introduced in Java 1.7, and results in less boilerplate than your first suggestion (new ArrayList<IScanIssue>()
) while avoiding the compiler warning generated by your second suggestion (List<IScanIssue> issues = new ArrayList()
).