Here is an example of what could go wrong without an appropriate conversion:
List<Object> l = new ArrayList<Object>(Arrays.asList("foo", "bar")); // Arrays.asList("foo", "bar").toArray() produces String[], // and l is backed by that array l.set(0, new Object()); // Causes ArrayStoreException, because you cannot put // arbitrary Object into String[]
axtavt
source share