This blog would be providing you one stop solution for the clean solutions towards solving the problem, instead of just giving just instruction and not actual code.

13 Oct 2013

How to convert Collection to Array?

No comments :
No talk, just the code.

package poc;

import java.util.ArrayList;
import java.util.List;

/**
 * @author CK
 *
 */
public class CollectionToArray {

 /**
  * @param args
  */
 public static void main(String[] args) {
  List arraylist = new ArrayList();
  arraylist.add("Apple");
  arraylist.add("Orange");
  arraylist.add("Grape");
  arraylist.add("Pear");
  Object[] array = arraylist.toArray();
  System.out.println("\nThe objects into array.");
  for(Object name: array)
  {
   System.out.println(name);
  }
 }
}


No comments :

Post a Comment