我有一个 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 中显示所有三个字符串,每行一个字符串?