I have a class like this:
public class TestObject
{
List<String> data;
public List<String> getData()
{
return data;
}
public void setData(List<String> inputData)
{
data = inputData;
}
}
I checked the option in Preferences -> Java -> Editor -> Save Actions -> Configure -> Unnecessary Code -> Remove redundant type arguments (1.7 or higher)
Now I create a Main class:
public class Main
{
public static void main(String[] args)
{
TestObject o = new TestObject();
o.setData(new ArrayList<String>());
}
}
Now I save the file.
I would have expected eclipse to remove the "String" type argument inside the setter on saving the file, but it stayed there.
Any ideas why this is the case (is there a reason for it or did I miss a setting I have to enable?)
It only remove for code like below:
If this is passed in method like your code, eclipse will not remove that.
Not sure exactly but as from the below bug looks like its only remove when type arguments is redundant.
See [1.7][clean up][quick assist] Remove unnecessary type arguments (was: Suggest to use <> where applicable)