J2ME text field to double

14,401

Solution 1

You can use Double.parseDouble(String) method for converting string to double:

double d = Double.parseDouble("22.4"); 

To get text of TextField you can use TextField.getString() method;

String text = TextField.getString();

So:

double d = Double.parseDouble(TextField.getString()); 

Solution 2

Make a note that floats are only supported on phones that conform to CLDC 1.1, if the phone you are targetting is CLDC 1.0 you will need to use fixed point

Share:
14,401
benjamin239
Author by

benjamin239

Updated on June 04, 2022

Comments

  • benjamin239
    benjamin239 almost 2 years

    Is there a way to convert the string from a text field to a double in j2me? And what is the name of the string that comes out of the text field?