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

来源:3-3 Java中的赋值运算符

yeezus_mac

2017-09-23 15:37

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回答

  • 层层嫩牛堡
    2017-09-23 15:44:22
    已采纳

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

    慕UI249...

    你后面要打小括号

    2017-11-11 20:13:00

    共 2 条回复 >

  • 马小跳666
    2017-09-23 15:48:14

    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 );     

        }


    yeezus...

    我需要输出是这样: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 13:14:24

    共 1 条回复 >

Java入门第一季(IDEA工具)升级版

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

1165172 学习 · 17581 问题

查看课程

相似问题