public class Main { public static void main(String[] args) { String str = "one,two,three,four,five"; String[] elements = str.split(","); for (int i = 0; i < elements.length; i++) System.out.println(elements[i]); } } /* one two three four five */