包装类练习2-13,烦请老师检查并指正~
来源:2-13 编程练习
Heijyu
2021-09-25 01:16:49
public class HelloWorld {
public static void main(String[] args) {
// 定义int类型变量,值为100
int score = 100;
// 创建Integer包装类对象,表示变量score1的值
Integer score1= new Integer(score);
// 将Integer包装类转换为double类型
double score2 = score1.doubleValue();
// 将Integer包装类转换为long类型
long score3 = score1.longValue();
// 将Integer包装类转换为int类型
int score4 = score1.intValue();
//打印输出
System.out.println("Initial number is: " + score);
System.out.println("Integer is: " + score1);
System.out.println("Double is: " + score2);
System.out.println("Long is: " + score3);
System.out.println("Int is: " + score4);
}
}
1回答
好帮手慕小小
2021-09-25
同学你哈,已完成练习,逻辑清晰,很好,继续加油!
相似问题