今天看別人寫的關於Java中split用法的一點小問題,文章如下:
用split()將字符串分割成數組,數組長度問題:
String a = "";
String[] b = a.split(",");
b.length為 1;
*
String a = "c";
String[] b = a.split(",");
b.length為 1;
**
String a = "c,,,";
String[] b = a.split(",");
b.length為 1;
***
String a = "c,,c";
String[] b = a.split(",");
b.length為 3;
****
String a = ",";
String[] b = a.split(",");
b.length為 0;