In the Conllection interface, there are actually two operations that can transform a collection into an array of objects
In the Conllection interface, there are actually two operations that can transform a collection into an object array list<string> addlist = new arraylist<string> (); Addlist.add ("Hi "); Addlist.add (0," Hello "); Addlist.add (" World "); Object obj[] = Addlist.toarray (); for (int i=0; i<obj.length; i++) { System.out.println (Obj[i]);}
You can also specify the type of generics at the time of output, which makes it easier to operate.
You can also specify the type of the generic at the time of the output, which makes it easier to manipulate String obj2[] = Addlist.toarray (new string[]{}); for (int j = 0; J < Obj2.length; J + +) {STR ing str = obj2[j]; System.out.println (str);}
Java: In the Conllection interface, there are actually two operations that can transform a collection into an array of objects