Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { private static String[] setPlacesToWatch(String placeWatch) { String[] places = { "" }; if (placeWatch != null && !placeWatch.equals("")) { StringTokenizer tok = new StringTokenizer(placeWatch, ","); List<String> l = new ArrayList<String>(); while (tok.hasMoreElements()) { l.add(tok.nextToken().toString()); } if (!l.isEmpty()) { //Object[] o = l.toArray(); places = new String[l.size()];// (String[])o; int idx = 0; for (String s : l) { places[idx++] = s; } } } return places; } }