且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 ArrayList 在 JOptionPane 中显示多行

更新时间:2023-11-22 16:38:52

您可以非常轻松地做到这一点.将这些行作为输出放在字符串中,然后在 JOptionPane 中打印.将数据添加到 arraylist 后,只需执行以下操作.

You can do this very easily. Put those lines in a String as an output and then print that in JOptionPane. After adding your data to arraylist just do the following.

String output = "";
for(int i = 0; i<games.size(); i++){
    String everything = sku.get(i).toString();
    String everything2 = games.get(i).toString();

    output += everything +" "+ everything2 + "\n";       
}
JOptionPane.showMessageDialog(null, output);