If you have a java version >= 1.7 you can use the diamond notation.
Instead of:
List<String> rows = new ArrayList<String>();
You can write:
List<String> rows = new ArrayList<>();
With Eclipse Mars-M4, I have errors when I use the first construct. (Maybe this was already the case with Eclipse Luna version. I did not check):

This is due to this configuration:
Preferences > Java > Compiler > Errors/Warnings in the tree. In the list: Generic Types > Redundant type arguments (1.7 or higher).

This is set to ERROR. I can of course configure it to IGNORE to remove the error.
I am searching for another solution. Eclipse has the notion of “Additional actions”. I am looking for an action that would rewrite the code to the diamond notation.
Does this action already exist? How can I configure it?
Related question:
Unfortunately this is not possible out of the box. You would need to write your own plugin and implement the ICleanUp interface.
If you wish to create your own plugin, details on how to create a cleanup and save action can be found here: Contributing a clean up and a save action using the clean up extension point
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With