我是一个菜鸟,请教一下这个程序的问题在哪?哪位帮帮忙,感激不尽!!!!!!!!

tandezhi820131 2008-04-26 05:32:19
public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double();
int aa=test.intValue(d1);

System.out.println(aa);
}

}
...全文
114 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
abner_me 2008-05-01
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 bhl_1986 的回复:]
Double test=new Double(); //首先,Double没有无参数构造方法!
int aa=test.intValue(d1);//intvalue()函数却是一个无参的函数

LZ代码应为:
public class T5 {

public static void main(String[] args) {
double a=1.23;
Double test=new Double(a); //将double型数据a包装到对象test中
int aa=test.intValue(); //强制转换成int型

System.out.println(aa);
}
}
[/Quote]
6楼,11楼都正确的。
也可以匿名类实现
public class T5 {
public static void main(String[] args){
double a=1.23;
int aa=new Double(a).intValue();
System.out.println(aa);
}

}

gongziy 2008-05-01
  • 打赏
  • 举报
回复

public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double(); //这个double好像不能这么用吧?
int aa=test.intValue(d1); //intValue能带参数么?

System.out.println(aa); //输出肯定错误.呵呵
}

}

这样还不显示?????
gongziy 2008-05-01
  • 打赏
  • 举报
回复

public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double(); //这个double好像不能这么用吧?
int aa=test.intValue(d1); //intValue能带参数么?

System.out.println(aa); //输出肯定错误.呵呵
}

}
试一下 代码的显示.呵呵.
gongziy 2008-05-01
  • 打赏
  • 举报
回复
public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double(); //这个double好像不能这么用吧?
int aa=test.intValue(d1); //intValue能带参数么?

System.out.println(aa); //输出肯定错误.呵呵
}

}
bhl_1986 2008-04-27
  • 打赏
  • 举报
回复
Double test=new Double(); //首先,Double没有无参数构造方法!
int aa=test.intValue(d1);//intvalue()函数却是一个无参的函数

LZ代码应为:
public class T5 {

public static void main(String[] args) {
double a=1.23;
Double test=new Double(a); //将double型数据a包装到对象test中
int aa=test.intValue(); //强制转换成int型

System.out.println(aa);
}
}
iverson817 2008-04-26
  • 打赏
  • 举报
回复
Double test=new Double(); //首先,Double没有无参数构造方法!
int aa=test.intValue(d1); //这里,不知道d1是哪里来的,必须是错误的!

这2句是什么意思·具体解释下啊·我觉得都没有什么函数调用啊·
tandezhi820131 2008-04-26
  • 打赏
  • 举报
回复
太感谢你们了,谢谢!!!!
anqini 2008-04-26
  • 打赏
  • 举报
回复
[Quote=引用楼主 tandezhi820131 的帖子:]
public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double();
int aa=test.intValue(d1);

System.out.println(aa);
}

}
[/Quote]


public class T5 {

public static void main(String[] args) {

double a=1.23;
Double test=new Double(); //首先,Double没有无参数构造方法!
int aa=test.intValue(d1); //这里,不知道d1是哪里来的,必须是错误的!

System.out.println(aa);
}

}
胡矣 2008-04-26
  • 打赏
  • 举报
回复

double a=1.23;
Double test=new Double(a);
int aa=test.intValue();
System.out.println(aa);
joejoe1991 2008-04-26
  • 打赏
  • 举报
回复
            double a=1.23; 
Double test=new Double(a);
int aa=test.intValue();
dthlgs_renjia 2008-04-26
  • 打赏
  • 举报
回复
double转到int需要强制转换吧
KKK2007 2008-04-26
  • 打赏
  • 举报
回复
intValue()是个无参数的函数,同时Double类的构造函数要有参数的
这样写就对了
public class tt {
public static void main(String[] args) {
double a=1.23;
Double test=new Double(a);
int aa=test.intValue();

System.out.println(aa);
}

}
晨星 2008-04-26
  • 打赏
  • 举报
回复
编译器给出的错误是什么?
tandezhi820131 2008-04-26
  • 打赏
  • 举报
回复
不好意思,写错了,应该是test.intValue(a);不过这样还是有问题哈。
kokobox 2008-04-26
  • 打赏
  • 举报
回复
int aa=test.intValue(d1);

lz这个d1是什么? 错在这里吧

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧