How to setText in a textArea from an ArrayList?
问题 I have an ArrayList ArrayList<String> externalDataList = new ArrayList<>(1600); and I would like to display in a textArea first 3 strings, but I can't succed: Here is my code 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++; } The sout correctly print first 3 strings element are: 23