博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java Double类parseDouble()方法的示例
阅读量:2532 次
发布时间:2019-05-11

本文共 1913 字,大约阅读时间需要 6 分钟。

Double类parseDouble()方法 (Double class parseDouble() method)

  • parseDouble() method is available in java.lang package.

    parseDouble()方法在java.lang包中可用。

  • parseDouble() method is used to return the double value corresponding to the given String or in other words we can say this method is used to convert a string value to double value.

    parseDouble()方法用于返回对应于给定String的double值,换句话说,我们可以说此方法用于将字符串值转换为double值。

  • parseDouble() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.

    parseDouble()方法是一个静态方法,也可以使用类名进行访问,如果我们尝试使用类对象访问该方法,那么我们也不会收到错误。

  • parseDouble() method may throw a NumberFormatException at the time of conversion from string double,

    从字符串double转换时, parseDouble()方法可能会引发NumberFormatException,

    NumberFormatException: In this exception, when the string argument does not have parsable double.

    NumberFormatException:在此异常中,当string参数没有可分析的double时。

Syntax:

句法:

public static double parseDouble(String str);

Parameter(s):

参数:

  • String str – represents the string value to be parsed.

    字符串str –表示要解析的字符串值。

Return value:

返回值:

The return type of this method is double, it returns the corresponding double value.

此方法的返回类型为double ,它返回相应的double值。

Example:

例:

// Java program to demonstrate the example // of parseDouble(String str) method of Double classpublic class ParseDoubleOfDoubleClass {
public static void main(String[] args) {
// Variables initialization String str1 = "100"; String str2 = "6.7"; // Object initialization Double d1 = new Double(str2); // It convert string into double by calling parseDouble() method // and store the result in another variable of double type double result = d1.parseDouble(str1); // Display result System.out.println("d1.parseDouble(str1): " + result); }}

Output

输出量

d1.parseDouble(str1): 100.0

翻译自:

转载地址:http://lixzd.baihongyu.com/

你可能感兴趣的文章
MySQL 处理重复数据
查看>>
关于typedef的用法总结(转)
查看>>
hibernate could not resolve property
查看>>
【strtok()】——分割字符串
查看>>
Linux下安装rabbitmq
查看>>
曹德旺
查看>>
【转】判断点在多边形内(matlab)
查看>>
java基础之集合:List Set Map的概述以及使用场景
查看>>
Python 线程 进程 协程
查看>>
骨牌覆盖问题
查看>>
iOS语言中的KVO机制
查看>>
excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法
查看>>
响应式web设计之CSS3 Media Queries
查看>>
实验三
查看>>
机器码和字节码
查看>>
环形菜单的实现
查看>>
Python 函数参数 传引用还是传值
查看>>
【解决Chrome浏览器和IE浏览器上传附件兼容的问题 -- Chrome关闭flash后,uploadify插件不可用的解决办法】...
查看>>
34 帧动画
查看>>
二次剩余及欧拉准则
查看>>