This method return an array that contains all the elements of ArrayList.
Example
import java.util.ArrayList; public class toArray { public static void main(String[] args) { ArrayListOutput:list = new ArrayList (); list.add("aa"); list.add("bb"); list.add("cc"); String[] array = new String[list.size()]; list.toArray(array); for(int i = 0 ; i < array.length; i++) System.out.println(array[i]); } }
aa bb cc
No comments:
Post a Comment