我有一个ArrayList ArrayList<String> externalDataList = new ArrayList<>(1600);
,我想在textArea中显示前3个字符串,但我不能成功:
这是我的代码
textareaShowPreview.setPrefRowCount(3);
Iterator<String> it = externalDataList.iterator();
int tot = 0;
while(it.hasNext() && tot<3){
String element = it.next();
textareaShowPreview.setText(element + "\n");
System.out.println("elements are: " + element);
tot++;
}
sout正确打印前3个字符串
element are: 23/05/2007 ,30.9455,31.2545,30.9091,30.9545,7518142
element are: 24/05/2007 ,30.6545,31.0909,30.5364,30.6909,12851606
element are: 25/05/2007 ,30.6636,30.8545,30.4818,30.8091,9392088
但是在textArea我只有第一个
我如何修改我的代码以在textArea中显示所有三个字符串,每行一个字符串?
答案 0 :(得分:5)