I have an EditField array which I use to get 4 different numeric inputs from the user. I use a for loop to initialize:
for (int i=0; i<4; i++)
myArray[i] = new EditField("", "0", 4, EditField.EDITABLE);
As you can see the default value is 0. I convert whatever the user enters to a double value and then do some calculations which works just fine. That is unless the user enters a null value or just deletes the default 0 value. Then I get an exception thrown because the array does not contain a valid number.
To avoid this I added the following code to check for a null value:
However I get this error now:
Uncaught exception thrown - NumberFormatException
It seems to me that the if
statement is not triggering the then
statement to set it back to the default 0 value.
I'm sure I'm making a very basic java mistake. Can anyone help me?