java的split的坑,会忽略空值
String test = "@@@@"; String[] arrayTest = test.split("\\@"); System.out.println(arrayTest.length);
输出为0,split为忽略空值,如果要想取得正确的值,需要:
String test = "@@@@"; String[] arrayTest = test.split("\\@",-1); System.out.println(arrayTest.length);
这时输出就是5了