Convert list to array in java

public class ListToArray {

 public static void main(String args[])
 {
  List list= new ArrayList();
  list.add("1");
  list.add("2");
  list.add("3");

  Object[] intArr = list.toArray();

  System.out.println("Value inf String Array is : "+intArr[0]+"-"+intArr[1]+"-"+intArr[2]);

 }
}

 

Leave A Comment

Your email address will not be published. Required fields are marked *