我想将 ArrayList 保存main()
到我的新 ArrayList 中,它是 getTles(ArrayList input_list_of_strings) 中的子字符串。我怎么做?我知道我们需要处理循环并将其添加到 subString。此外,我想将代码中的字符串单词分解为小的子字符串。示例:“SCHOOLWORK”将分解为“SC”、“HOO”、“LWO”、“RK”。
import java.util.ArrayList;
public class HW2 {
public static ArrayList getTiles(ArrayList input_list_of_strings) {
// create a substring by go through the loop first, then .... (instruction)
ArrayList<String> subString = new ArrayList<>();
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));
}
}