应该没毛病吧?

应该没毛病吧?

public class HelloWorld {
    public static void main(String[] args) {
    	// 定义int类型变量,值为100
		int score = 100; 
		// 创建Integer包装类对象,表示变量score1的值
		   Integer score1=score;     
		// 将Integer包装类转换为double类型
		     double a=score1.doubleValue();   
		// 将Integer包装类转换为Long类型
		     Long b=score1.longValue();   
		// 将Integer包装类转换为int类型
		    int c=score1.intValue();
		//打印输出
		System.out.println("score对应的Integer类型结果为:"+score1);
		System.out.println("score对应的double类型结果为:"+a);
		System.out.println("score对应的long类型结果为:"+b);
		System.out.println("重新由Integer转换为int类型结果为:"+c);
	}
}


正在回答

登陆购买课程后可参与讨论,去登陆

2回答

代码没有问题,继续努力,加油~~

  • qq_小梁_3 提问者 #1
    非常感谢!
    2017-08-24 14:25:29
一种没有脚的鸟 2018-02-21 19:46:43

    Long b=score1.longValue();  
中的Long应该是long吧

  • 都可以的,long是基本数据类型,Long是包装类。
    2018-02-21 20:16:07
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师