package step2;
public class Task {
public static void main(String[] args) {
// 定义int类型变量,值为67
int score = 67;
// 创建Integer包装类对象,表示变量score的值
Integer score1 = new Integer(score);
// 将Integer包装类转换为double类型
double score2 = score1.doubleValue() ;
// 将Integer包装类转换为float类型
float score3 = score1.intValue() ;
// 将Integer包装类转换为int类型
int score4 = score1. intValue() ;
System.out.println("Integer包装类:" + score1);
System.out.println("double类型:" + score2);
System.out.println("float类型:" + score3);
System.out.println("int类型:" + score4);
}
}
包装类 2包装类转换成其他数据类型
最新推荐文章于 2024-01-05 13:00:45 发布