Import Java. lang. reflect. array; import Java. util. *; public class collection {public static void main (string ARGs []) {arraylist list = new arraylist (); list. add (1); list. add (2); list. add (3); // convert the window to an Array Using toarray // integer integerarray [] = (integer []) list. toarray (); // This method is incorrect. toarray can only be converted to an array of objects. // object objectarray [] = List. toarray ();/** The following describes another toarray method usage. t [] toarray (t a []) is converted to an array of the corresponding type, there must be a premise for this conversion, that is, the data stored in the arraylist is of this type, so that it can be converted to a type array, you cannot change it to another type. ***/arraylist <integer> newlist = new arraylist <integer> (); newlist. add (1); newlist. add (2); newlist. add (3); newlist. add (4); // write the statement correctly. Convert the type stored in the container to the corresponding array integer integerarray [] = newlist. toarray (new integer [4]); // The following method is incorrect // long longarray [] = newlist. toarray (New long [4]); // This contains type conversion, so error}/** remember one .. toarray can only be converted into arrays, but cannot be converted into arrays. **/21:19:38