现有字符串为双 [英] Existing String to Double

查看:115
本文介绍了现有字符串为双的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将现有字符串更改为双倍。我有这样的代码声明为字符串,但实际上它从数据库中获取数字..我正在做数字转换,但现在我不想将其转换为字符串,并得到它所有的方式作为数字

How can I change existing string into double. I have code like this declared as string but in reality its getting number from the database.. I was doing sting to number conversion but now i dont wanna convert it as string and get it all the way as number

 private String _example1;

_example1 = new String();

public String getExample1() {
        return _example1;
    }

    public void setExample1(String s) {
        _example1 = s;
    }

所以我只是在上面的代码中改变了双字的String字。 / p>

so i just changed the String word with double in the above code..

private Double _example1;

    _example1 = new Double();

    public Double getExample1() {
            return _example1;
        }

        public void setExample1(Double s) {
            _example1 = s;
        }

但我收到此错误

[exec] com\sample\jack\javabean\ExampleBean.java:48: cannot resolve symbol
     [exec] symbol  : constructor Double ()
     [exec] location: class java.lang.Double
     [exec]             _example1 = new Double();
     [exec]                                 ^

[exec] com\sample\jack\javabean\ExampleBean.java:134: setExample1(java.lang.Double) in com.sample.jack.javabean.ExampleBean cannot be applied to (double)
     [exec]                             this.setExample1(cstmt.getDouble(2));
     [exec]                                 ^

有人可以告诉我我要做什么才能正确谢谢

Can someone tell me what I have to do to get it right.. Thank you

推荐答案

双重是不可变的,必须用一个值(没有一个无参数构造函数): http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html

Double is immutable and must be constructed with a value (there is not a no-arg constructor): http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html

这篇关于现有字符串为双的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆