Hi there I have a problem that seems straight forward but the answer eludes me. I have done some Java (SE) but am dabbling with J2ME.
I am trying to write a program that calculates the total cost of a journey by entering miles, mpg and cost of fuel etc.
I have got a problem with a textfield and converting the returning String to an int. I can get it to return a value that is typed in to the textfield but when it tries to return the contents of an empty textfield (ie nothing typed in there) a NumberFormatException is thrown.
The following code is a section of the program that I would expect to run without problem but doesnt.
I have tried replacing the if statement with various values ie milesStVal=="" and milesStVal==" " and milesStVal==null but nothing changes.
What is returned when using the getString() method of a texfield? I assume it would either be "" or null? As I say adding these data types to the if statement doesnt seem to make any difference.