我试图按照标题所说的那样做,但我目前得到了错误的输出,我在这段代码中做错了什么?
public void AAAAA(String thetext, int numb)
{
List<String> items = new LinkedList<String>(Arrays.asList(thetext.split(" "))); //split string to individual characters
int len = items.size(); //get size of string
for(int j = 0; j < len; j++){ // loop through list
if(j % width == 0){
items.add(numb, "\n");
}
}
System.out.println(items);
}
}
文本示例:“你好,我叫鲍勃,我喜欢抚摸可爱的肥狗”
预期输出如果numb是 3;
hello my name
is bob i
like to pet
cute fat dogs
千巷猫影
SMILET
相关分类