ImmutableList.of(E[]) does not store and never stores the array specified by it (this would not be immutable if it happened to defeat a class point). It was deprecated to explain the reasons. If you look at the implementation, this is:
public static <E> ImmutableList<E> of(E[] elements) { return copyOf(elements); }
So my advice would be to simply use ImmutableList.copyOf() as a whole. If you know that you are just wrapping the array for internal use or some of them, feel free to save a copy and just use Arrays.asList , but I would prefer ImmutableList for the API.
Colind
source share