Notice: Constant WP_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 107

Notice: Constant WP_MAX_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 108
String to double in java - CodesJava

CodesJava

Easy learning with example program codes

String to double in java


Notice: Undefined variable: footnotelist in /home/javawith/public_html/codesjava.com/wp-content/plugins/latex2html/inc/core.php on line 475

Java convert string to double using Double.parseDouble(String)

package com.codesjava;
 
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);
  }
}

Output:

546.307

Download this example.

Java convert string to double using Double.valueOf(String)

package com.codesjava;
 
public class StringToDouble {
  public static void main(String args[]){
	String str="546.307";
 
	//convert String to double
	double var= Double.valueOf(str);
	System.out.println(var);
  }
}

Output:

546.307

Download this example.

Please follow and like us:
error
Posted in Java   

Core Java Tutorial








Copyright © 2019 CodesJava DMCA.com Protection Status