以下程序:
class="java" name="code">String str1 = "a,b,,,,"; System.out.println("String length is: " + str1.split(",").length); String str2 = "a,b,,,,c"; System.out.println("String length is: " + str2.split(",").length);
?输出:
String length is: 2 String length is: 6
?