How can I generate Java 8 specific code in eclipse IDE. For example using collections, on pressing CNTL + ENTER
; instead of generating following
Collection<String> list = new ArrayList<String>();
it should generate
Collection<String> list = new ArrayList<>();
NOTE: However CNTL + 1
does convert the anonymous interface to lambda expression.
You should choose the correct JRE System Library for your project and the autocompletion will change accordingly to the Java version used.
I have created a project named test-java-1.6
and I have verified that the Java autocomplete does not support diamond operator because of old java version.
The autocomplete behaviour changed immediately after the Java version update.
Here how to specify the java execution environment:
And how to change it to a newer version, here you should choose JavaSE-1.8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.