Convert existing generics to diamond syntax

Oh yes, I have successfully done this on IntelliJ (free Community Edition).

Menu > Analyze > Inspect Code…

In the result, select “Java language level migration aids > Explicity type can be replaced with <>”

Right click, run “Apply Fix ‘Replace with <>'” And you got diamonds.

There was a bug about diamond on anomymous classes, so some code may not compile after the fix. You’ll have to revert them back then.

// anonymous class, <> doesn't work.
new Factory<Pig>(){ ... }  
// however IntelliJ may wrongly "fix" it to
new Factory<>(){ ... }   // does not compile.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)