public class Chks { public static void main(String[] args) { System.out.println(String.format("Version: %s", System.getProperty("java.version"))); String[] parts1 = "A,B,C".split(",", -1); String[] parts2 = "A,,C".split(",", -1); String[] parts3 = "A, ,C".split(",", -1); String[] parts4 = " , , ".split(",", -1); String[] parts5 = ",,".split(",", -1); check(1, parts1); check(2, parts2); check(3, parts3); check(4, parts4); check(5, parts5); } private static void check(int idx, String[] strs) { System.out.print(String.format("%d : strs:[%d];", idx, strs.length)); for(String item : strs) { try { System.out.print(String.format("var:[%s];", item)); if (item == null) System.out.print("null;"); if (item == "") System.out.print("zeroLen;"); if (item.isEmpty()) System.out.print("empty;"); System.out.print(String.format("len=%d;", item.length())); } catch (Exception e) { //e.printStackTrace(); } } System.out.println(); } }