请老师检查下错误在哪?
来源:2-13 编程练习
albert_aGHTZ7
2022-07-15 16:16:16
public class HelloWorld {
public static void main(String[] args) {
// 定义int类型变量,值为100
int score = 100;
// 创建Integer包装类对象,表示变量score1的值
Integer score1=score;
// 将Integer包装类转换为double类型
double two=score1.doublevalue();
// 将Integer包装类转换为long类型
long three=score1.longvalue();
// 将Integer包装类转换为int类型
int four=score1.intvalue();
//打印输出
System.out.println("score对应的Integer类型的结果为:"+score1);
System.out.println("score对应的double类型结果为:"+two);
System.out.println("score对应的long类型结果为:"+three);
System.out.println("重新由Integer转换为int类型的结果为:"+four);
}
}
1回答
好帮手慕小黑
2022-07-15
同学你好,将Integer包装类转换为double类型时,方法名doublevalue书写有误,应该写为doubleValue,同理Integer包装类转换为long类型和Integer包装类转换为int类型时,方法名书写有误,应该写为longValue和intValue。
祝学习愉快!