Nov 1, 2018

Java Arrays.asList Example

    List<String> exampleBetterPerformance = Arrays.asList("FIRST_NAME","LAST_NAME","EMAIL");
    
    List<String> exampleImmutable = new ArrayList<String>(Arrays.asList("FIRST_NAME","LAST_NAME","EMAIL"));

The first one has better performance. But it returns a List with an immutable size. You cannot add/remove elements to/from it:

Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.)