JAVA把字符串以某个字符分成几段再存入String [ ]数组中

2024-11-05 08:29:53
推荐回答(2个)
回答(1):

根据下划线分隔"_"分隔;

String s = "asd_sd_ao_acanv_sd_";
String as [ ] = s.split("_");

for(int i = 0; i < as.length; i++) {
a[i] = as[i];

}

回答(2):

String s = "asd_sd_ao_acanv_sd_";
String a [ ] = s.split("_");