J2EEScan icon indicating copy to clipboard operation
J2EEScan copied to clipboard

about generics

Open c3stbon opened this issue 8 years ago • 1 comments

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

c3stbon avatar Jul 25 '16 06:07 c3stbon

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()).

dnet avatar Jan 24 '17 11:01 dnet