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

String text = "12.34"; // example String
double value = Double.parseDouble(text);

For your case it looks like you want:

double total = Double.parseDouble(jlbTotal.getText());
double price = Double.parseDouble(jlbPrice.getText());
Answer from WhiteFang34 on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › double-parsedouble-method-in-java-with-examples
Double parseDouble() method in Java with examples - GeeksforGeeks
July 11, 2025 - Return type: It returns e double value represented by the string argument. Exception: The function throws two exceptions which are described below: NullPointerException- when the string parsed is null · NumberFormatException- when the string parsed does not contain a parsable float Below is the implementation of the above method. Program 1: ... // Java Code to implement // parseDouble() method of Double class class GFG { // Driver method public static void main(String[] args) { String str = "100"; // returns the double value // represented by the string argument double val = Double.parseDouble(str); // prints the double value System.out.println("Value = " + val); } }
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
The double keyword is a data type that can store fractional numbers from 1.7e−308 to 1.7e+308. ... Read more about data types in our Java Data Types Tutorial. ... If you want to use W3Schools services as an educational institution, team or ...
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java double parsedouble method
Java Double parseDouble Method
September 1, 2008 - The Java Double parseDouble(String s) method returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
🌐
Stack Overflow
stackoverflow.com › questions › 72652140 › i-want-to-parse-a-string-and-get-a-double-value-java
I want to parse a string and get a double value (java) - Stack Overflow
Because at least part of the String can't be converted to a double, you need to remove that part of the String before you can use parseDouble on it.
🌐
Javatpoint
javatpoint.com › java-double-parsedouble-method
Java Double parseDouble() Method - Javatpoint
The parseDouble method of Java Double class returns a new double value that is initialized to the value corresponding to defined String. - Learn basics of Java Double parseDouble() Method
🌐
LabEx
labex.io › tutorials › java-java-double-parsedouble-method-117627
double.parsedouble in Java | LabEx
This will execute the Java program ... not possible to convert null to double value · In this lab, we learned how to use the parseDouble() method to convert string values to their equivalent double values....
🌐
Tabnine
tabnine.com › home page › code › java › java.lang.double
Java Examples & Tutorials of Double.parseDouble (java.lang) | Tabnine
@Override protected void checkParameters(String attribute, String value) { super.checkParameters(attribute, value); if (PARAM_QUALITY_FACTOR.equals(attribute)) { value = unquote(value); double d = Double.parseDouble(value); Assert.isTrue(d >= 0D && d <= 1D, "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); } }
Find elsewhere
🌐
Coderanch
coderanch.com › t › 595201 › java › parse-Double-parseDouble
What is parse? (Double.parseDouble();)? (Beginning Java forum at Coderanch)
What happens in your code is that user is prompted to enter a number that is stored as a String in userInput variable. Since you want to operate with the value entered as with a number (calculate the sum), you get double value represented as userInput String by using mentioned method (bolded ...
🌐
W3Schools
w3schools.com › java › java_strings.asp
Java Strings
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... Strings are used for storing text. A String variable contains a collection of characters surrounded by double quotes (""):
🌐
W3Schools Blog
w3schools.blog › home › java string to double
Java String to double - W3schools
March 18, 2018 - Java convert string to double: public class StringToDouble { public static void main(String args[]){ String str="546.307"; //convert String to double double var= Double.parseDouble(str); System.out.println(var); }}
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › how-to-convert-string-to-double-in-java
Java Convert String to Double examples
public class JavaExample{ public ... of variable dnum System.out.println(dnum); } } ... Double class has a constructor which parses the String argument that we pass in the constructor, and returns an equivalent double value....
🌐
Baeldung
baeldung.com › home › java › java string › convert string to double in java
Convert String to Double in Java | Baeldung
January 8, 2024 - In this tutorial, we’ll cover many ways of converting a String into a double in Java. We can convert a String to a double using the Double.parseDouble method:
🌐
Coderanch
coderanch.com › t › 729127 › java › Double-parseDouble-sc-nextLine-don
d = Double.parseDouble(sc.nextLine()); I don't understand this line of code (Beginning Java forum at Coderanch)
So Double,parseDouble( Strikng string ) is invoking the Double class static method which takes a String as its argument and returns a double value if the string can be interpreted as representing a double value, or it throws an exception if the string does not represent a double value.
🌐
Programiz
programiz.com › java-programming › examples › string-to-double-conversion
Java Program to convert string variables to double
To learn more, visit the Java Wrapper Class. Note: The string variables should represent the number value. Otherwise, the compiler will throw an exception. For example, class Main { public static void main(String[] args) { // create a string variable String str1 = "Programiz"; // convert string to double // using parseDouble() double num1 = Double.parseDouble(str1); // print double values System.out.println(num1); // throws NumberFormatException } }
🌐
Software Testing Help
softwaretestinghelp.com › home › java › methods to convert java string to double [with examples]
Methods To Convert Java String To Double [With Examples]
April 1, 2025 - In this tutorial, we will learn to convert Java string to double data type using four different methods along with programming examples.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-convert-string-to-double
Java Convert String to double | DigitalOcean
August 3, 2022 - Let’s look at all the different ways to convert string to double in java. We can parse String to double using parseDouble() method. String can start with “-” to denote negative number or “+” to denote positive number. Also any trailing 0s are removed from the double value.
🌐
Studytonight
studytonight.com › java-wrapper-class › java-double-parsedouble-method
Java Double parseDouble() Method - Studytonight
Enter Value 855.88 Equivalent Double value is : 855.88 **************************************** Enter Value -445.6 Equivalent Double value is : -445.6 **************************************** Enter Value 0x554 Invalid Input!! Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.