I'm trying to write a method for requesting user input via dialog box multiple times which only stops requesting when an empty string is entered.
Each entry needs to be added to a list, which I'll call aList. I'm using a bespoke import for the dialog box in my program which you may not be familiar with called Dialog.request("");.
I dont necessarily have to use this but I do need a pop up dialog box which only closes when an empty string is entered or cancel is pressed. Hopefully you can help
public void addToList()
{
String inputName = Dialog.request("Please Enter A Name");
aList.add(inputName);
}
With the while loop it is as follows
public void addToList()
{ String inputName = Dialog.request("Please Enter A Name");
while(inputName !=""){
aList.add(inputName);
}
}
I tried to implement a while loop but that lead to the following error
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError at unknown line
Any tips are appreciated. So far invoking the method with x.addToList(); only adds one entry at a time. When I put in the while loop or do-while loop I get the error
do-whileis appropriate