gpt4 book ai didi

java - 显示一个 ArrayList?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:14:27 26 4
gpt4 key购买 nike

ArrayList <String> cdcollection = new ArrayList();

private void initButtonActionPerformed(java.awt.event.ActionEvent evt) {
Collections.addAll(cdcollection, "small", "mayre", "brown", "evner", "rain" );
initButton.setEnabled(false);

}

private void displayButtonActionPerformed(java.awt.event.ActionEvent evt) {

for (int i = 0; i < cdcollection.size(); i++) {
mainTextArea.setText(cdcollection.get(i));
}
}

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
cdcollection.add(cdtitleInput.getText());
}

private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {
cdcollection.remove(cdcollection.size()-1);
}

当我运行它并单击显示按钮时,只会出现最后一个 CD 标题(rain)...如何让所有五个 CD 标题都出现在一行中?

最佳答案

使用Append()代替setText()

关于java - 显示一个 ArrayList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10688928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com