我有一个字符串
String strNumbers = "One,Two,Three,Four,Five";
O 想拆分这个字符串并产生
One
Two
Three
Four
Five
请帮帮我。
我正在使用以下代码
String strNumbers = "One,Two,Three,Four,Five";
//split the string using split method of String class
String[] numbers = strNumbers.split(",");
//create new ArrayList object
ArrayList<String> aListNumbers = new ArrayList<String>();
//add individual numbers to the ArrayLists
for(int i=0; i< numbers.length; i++){
aListNumbers.add(numbers[i]);
}