0 votes
1 view
in Java by (3.2k points)
How can I convert a string such as "12.34" to a double in Java?

1 Answer

0 votes
by (39.8k 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
Welcome to Intellipaat Community. Get your technical queries answered by top developers !