为了账号安全,请及时绑定邮箱和手机立即绑定

请问第六行哪里出问题了?

public class HelloWorld{

    public static void main(String[] args) {

    int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        three=one+two=30;

        System.out.println(three);

        three+=one=40;

        three-=one=30;

        three*=one=300;

        three/=one=30;

        three%=one=0;

        System.out.println(three+=one);

        System.out.println(three-=one);

        System.out.println(three/=one);

        System.out.println(three%=one);


正在回答

3 回答

一个句子之中只能有一个=号

0 回复 有任何疑惑可以回复我~
public class HelloWorld {
    public static void main(String[] args) {
        int one = 10 ;
        int two = 20 ;
        int three = 0 ;

        three=one+two;
        System.out.println(three);

        three+=one;
        System.out.println(three);

        three-=one;
        System.out.println(three);

        three*=one;
        System.out.println(three);

        three/=one;
        System.out.println(three);
        
        three%=one;
        System.out.println(three);
    }
}


0 回复 有任何疑惑可以回复我~

左面等于号算数运算符,右面是赋值运算符,题目的意思是让你得到这些结果,不是让你去赋值,three=one+two;

three此时的值已经是30了,达到题目要求,同理下面也是这样,因此你可以在每一行后面都进行一次输出,System.out.println(three);

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第一季(IDEA工具)
  • 参与学习       1168364    人
  • 解答问题       18754    个

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

进入课程

请问第六行哪里出问题了?

我要回答 关注问题
微信客服

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

帮助反馈 APP下载

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

公众号

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