String[] data = { "First", "Second", "Third" };
StringBuilder sb = new StringBuilder();
for (String item : data) {
sb.append(item).append(", ");
}
sb.setLength(sb.length() - 2);
// generates output:
// First, Second, Third
List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");
String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);
for(String s : stockArr)
System.out.println(s);