How to obtain Array from an ArrayList ?

How to obtain Array from an ArrayList ?

Array can be obtained from an ArrayList using toArray() method on ArrayList.
 List<String> list = new ArrayList<String>();
 list.add("India");
 list.add("Switzerland");
 String [] countries = list.toArray(new String[list.size()]);

Read More →