java.lang.Double.parseDouble()方法

声明

java.lang.Double.parseDouble()方法

public static double parseDouble(String s) throws NumberFormatException

参数

  • s -- This is the string to be parsed.

返回值

此方法返回的字符串参数表示的double值.

异常

  • NumberFormatException -- 如果字符串不包含可解析的double.

实例

package com.yiibai;
 
import java.lang.*;
 
public class DoubleDemo {
 
   public static void main(String[] args) {
 
     Double d = new Double("6.35");
   
     // returns the double value represented by the string argument
     String str = "50";
     double retval = d.parseDouble(str);
     System.out.println("Value = " + retval);
   }
} 

让我们来编译和运行上面的程序,这将产生以下结果:

Value = 50.0

下面的例子显示java.lang.Double.parseDouble()的使用方法.

猜你喜欢

转载自blog.csdn.net/xieganyu3460/article/details/81750698