# Remove Collection::addAll
|First seen in jSparrow version||3.15.0|
|Minimum Java version||1.2|
|Remediation cost||2 min|
In order to apply the rule, the following two statements must occur:
- A declaration of a local variable storing an instance of
java.util.Collectionwhich is initialized with the default constructor.
- An invocation of
java.util.Collection#addAllimmediately following the variable declaration.
Reducing lines of code and improving readability.
# Code Changes
List<String> list = new ArrayList<>(); list.addAll(Arrays.asList("value1", "value2"));
List<String> list = new ArrayList<>(Arrays.asList("value1", "value2"));
Automatic Application of This Rule
The automatic application of this rule is supported in the following jSparrow version:
You & jSparrow