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

请问我这样写代码哪里不对?

public class HelloWorld{

    public static void main(String[] args) {

   int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        int num1=one+two;

        int num2=three+=one;

        int num3 =three-=one;

        int num4 =three*=one;

        int num5 =three/=one;

        int num6 =three%=one;

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

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

        System.out.println("three = one -= two ==>"+num3);

        System.out.println("three = one *= two ==>"+num4);

        System.out.println("three = one /= two ==>"+num5); 

        System.out.println("three = one %= two ==>"+num6);     

    }


正在回答

2 回答

一条语句中不可有两个赋值符号

2 回复 有任何疑惑可以回复我~
#1

yeezus_mac 提问者

您是说我定义变量里面的“=”吗?第一个是赋值,第二个是运算符啊?
2017-09-26 回复 有任何疑惑可以回复我~
#2

慕UI2491424

你后面要打小括号
2017-11-11 回复 有任何疑惑可以回复我~

public class HelloWorld{

    public static void main(String[] args) {

   int one = 10 ;

        int two = 20 ;

        int three = 0 ;

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

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

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

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

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

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

    }


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

yeezus_mac 提问者

我需要输出是这样:three = one + two ==>30 three = one += two ==>10 three = one -= two ==>0 three = one *= two ==>0 three = one /= two ==>0 three = one %= two ==>0 我在eclipse上编译都通过的,不知道为什么在这儿没有通过
2017-09-26 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

请问我这样写代码哪里不对?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信