Convert list to array in Java [duplicate]
Either: or: Note that this works only for arrays of reference types. For arrays of primitive types, use the traditional way: Update: It is recommended now to use list.toArray(new Foo[0]);, not list.toArray(new Foo[list.size()]);. From JetBrains Intellij Idea inspection: There are two styles to convert a collection to an array: either using a pre-sized array (like … Read more