J2ME text box doubles

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

+3
source share
3 answers

You can use the Double.parseDouble (String) method to convert a string to double:

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

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

String text = TextField.getString();

So:

double d = Double.parseDouble(TextField.getString()); 
+3
source

Please note that floats are only supported on phones that comply with CLDC 1.1, if CLDC 1.0 is installed on your target phone, you will need to use a fixed point

+1
source

String s = txtField.getText();

double number1 = Double.parseDouble(s);
-1

Source: https://habr.com/ru/post/1727150/


All Articles