我正在尝试格式化一个字符串,每个单词之间的空格数需要根据每个字符串进行更改。我已经完成了计算所需空格数量的代码。我创建了一个包含多个“”元素的数组,我用这些元素来更改每个单词之间的空格数。如何打印数组中的 X 到 Y 元素?
blankarrayList.get(1-2) // just prints the item in position -1
blankarrayList.get(1,2) // just prints items one and two, this works but
// doesnt allow me to easily change the number printed (that i know of)
public static String format(List<String> myWords) {
System.out.println(myWords.get(0) + blankarrayList.get(/*array positions 1 through 3*/)
+ myWords.get(1) + blankarrayList.get(/*array positions 1 through 3*/)
+ myWords.get(2) + blankarrayList.get(/*array positions 1 through 3*/)
+ my words.get(3));
return myWords.get(0);
}
人到中年有点甜
相关分类