Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Java by (4k points)
How can I convert a string such as "12.34" to a double in Java?

1 Answer

0 votes
by (46k points)

You can try Double.parseDouble() to change a String into a double:

String text = "12.34"; // example String

double value = Double.parseDouble(text);

For your situation it seems like you require:

double total = Double.parseDouble(jlbTotal.getText());

double price = Double.parseDouble(jlbPrice.getText());

Related questions

0 votes
1 answer
0 votes
1 answer
asked Aug 6, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...