我怎么拆ArrayList的字符串 功课 阳台 坚持 硝石 BOLTON 俗气 CLIENTELE分裂ArrayList的字符串
我想要拆分那些话为 “SCH”, “OOL”, “WO”,“ RK”。
这里是我的代码
import java.io.File;
import java.util.ArrayList;
public class HW2 {
public static ArrayList<String> getTiles(ArrayList<String> input_list_of_strings) {
// create a substring by go through the loop first, then .... (instruction)
Object[] subString = new Object[input_list_of_strings.size()];
for (int i = 0; i < input_list_of_strings.size(); i++) {
subString[i] = input_list_of_strings.get(i);
// test just want to see if subString get all String
// System.out.println(subString[i]);
String delim=" ";
String[] splitstrings = ((String) subString[i]).split(delim);
for (int j = 0; j < splitstrings.length; j++) {
splitstrings[j] +=delim;
System.out.println(splitstrings[j]);
}
}
return input_list_of_strings;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> input_words = new ArrayList<String>();
input_words.add("SCHOOLWORK");
input_words.add("BALCONY");
input_words.add("INSIST");
input_words.add("SALTPETER");
input_words.add("BOLTON");
input_words.add("KITSCHY");
input_words.add("CLIENTELE");
System.out.print(getTiles(input_words));
}
}
谢谢......通过你的ArrayList<String>
什么是你的问题?问题是什么?分割字符串的确切标准是什么? –
什么应该是确切的标准来分割一个字符串? – Krease
如何分开单词,决定性因素是什么?真的没有任何直觉的方式让我知道你想让'SCHOOLWORK'分裂为'SCH','OOL','WO','RK'而不是'SCHOOL','WORK'。你能解释一下它背后的驱动逻辑吗? – Grambot