public static void main(String[] args) {
ArrayList<String> names = new ArrayList<String>();
names.add(JOptionPane.showInputDialog("Enter type of pie"));
}
我如何循环这个语句?我尝试过 dowhile (!names.equalsIgnoreCase("q"));
但找不到它。
names.add(JOptionPane.showInputDialog("Enter type of pie"));
最佳答案
这工作正常。
String str = null;
List<String> names = new ArrayList<String>();
do
{
str = JOptionPane.showInputDialog("Enter type of pie");
if(!str.equalsIgnoreCase("q"))
names.add(str);
}while(!str.equalsIgnoreCase("q"));
关于java - 如何在数组列表中循环添加语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31359147/