1Integer[] spam = new Integer[] { 1, 2, 3 };
2List<Integer> list = Arrays.asList(spam);
1List<String> list = new ArrayList<>();
2list.add("a");
3list.add("ab");
4list.add("abc");
5list.add("abcd");
6// convert
7String[] array = list.toArray();
1/*
2Get the Array to be converted.
3Create the List by passing the Array as parameter in the constructor of the List with the help of Arrays. asList() method.
4Return the formed List.
5*/
6
7String[] namedata = { "ram", "shyam", "balram" };
8
9List<String> list = Arrays.asList(namedata);
1List<String> stockList = new ArrayList<String>();
2stockList.add("stock1");
3stockList.add("stock2");
4
5String[] stockArr = new String[stockList.size()];
6stockArr = stockList.toArray(stockArr);
7
8for(String s : stockArr)
9 System.out.println(s);