Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about generics #9

Open
c3stbon opened this issue Jul 25, 2016 · 1 comment
Open

about generics #9

c3stbon opened this issue Jul 25, 2016 · 1 comment

Comments

@c3stbon
Copy link

c3stbon commented Jul 25, 2016

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

@dnet
Copy link

dnet commented Jan 24, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants