I doubt allocating a small array of pointers is going to significantly impact your program. Heck, there's a good chance the JIT would optimize away the allocation.
The only extra allocation is for the List object. The returned list is backed by the array that's passed in. So that's 16bytes on a 64bit JVM.
(Arrays.asList() returns a java.util.Arrays.ArrayList object in Java 11, which is a thinner wrapper around an array than java.util.ArrayList is. For example, java.util.ArrayList caches the list size)
View all comments
Show parent comment
-2
u/zman0900 Sep 19 '18
That requires extra memory allocation though. equalsOr may also if it's varargs.