String s="s,s,s,s,,,,,,,"; System.out.println(s.split(",").length); // 4 System.out.println(s.split(",",-1).length); // 11