Update performance.xml
Added note about Arrays.asList()
This commit is contained in:
@ -790,6 +790,11 @@ public class SimpleTest extends TestCase {
|
||||
<description>
|
||||
The java.util.Arrays class has a "asList" method that should be used when you want to create a new List from
|
||||
an array of objects. It is faster than executing a loop to copy all the elements of the array one by one.
|
||||
|
||||
Note that the result of Arrays.asList() is backed by the specified array,
|
||||
changes in the returned list will result in the array to be modified.
|
||||
For that reason, it is not possible to add new elements to the returned list of Arrays.asList() (UnsupportedOperationException).
|
||||
You must use new ArrayList<>(Arrays.asList(...)) if that is inconvenient for you (e.g. because of concurrent access).
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
@ -834,7 +839,7 @@ an array of objects. It is faster than executing a loop to copy all the elements
|
||||
public class Test {
|
||||
public void foo(Integer[] ints) {
|
||||
// could just use Arrays.asList(ints)
|
||||
List l= new ArrayList(10);
|
||||
List<Integer> l= new ArrayList<>(100);
|
||||
for (int i=0; i< 100; i++) {
|
||||
l.add(ints[i]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user