public class MyClass {
public static void main(String args[]) {
String s = "java,,,c++,,php,python";
String[] arr = s.split(",");
for (String str : arr) {
System.out.println(str);
}
// Move the delimiters to end of string and split() will ignore them
s = "java,c++,php,python,,,,,";
arr = s.split(",");
System.out.println("-------");
for (String str : arr) {
System.out.println(str);
}
}
}
/*
run:
java
c++
php
python
-------
java
c++
php
python
*/