Search code examples
javajit

Do the Java or JIT compilers optimise Arrays.asList when the parameters are unchanged?


Eg: Arrays.asList("1", "2", "3")

Would this create a new array (for varargs) and a new ArrayList every time it is called during the lifetime of the app?


Solution

  • The returned list is mutable. This must return a different List with each call.