为啥我一个一个输出老是运行失败

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

a苏颜

2020-02-05 13:12

three = one + two; System.out.println("three=one+two==>"+three); three += one; System.out.println("three+=one==>"+three); three -= one; System.out.println("three-=one==>"+three); three *= one; System.out.println("three*=one==>"+three); 为什么我一个一个输出运行失败了

写回答 关注

4回答

  • 慕九州9121542
    2020-02-12 02:43:05

    public class HelloWorld{
        public static void main(String[] args) {
         int one = 10 ;
            int two = 20 ;
            int three = 0 ;
            System.out.println("three = one + two ==>"+ (three=one+two));
            System.out.println("three += one ==>"+ (three+=one));
            System.out.println("three -= one ==>"+ (three-=one));
            System.out.println("three *= one ==>"+ (three*=one));
            System.out.println("three /= one ==>"+ (three/=one));
            System.out.println("three %= one ==>"+ (three%=one));
     }
    }

    不用增加变量,直接输出。

  • 我的未来道路
    2020-02-06 15:43:17

    public class HelloWorld{

        public static void main(String[] args) {

        int one = 10 ;

            int two = 20 ;

            int three = 0 ;

             int a=three=one+two;

             int b=three+=one;

             int c=three-=one;

             int d=three*=one;

             int e=three/=one;

             int f=three%=one;

             

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

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

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

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

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

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


  • 木林森丿
    2020-02-05 20:23:53

     int one = 10 ;        int two = 20 ;        int three = 0         three=one+two;        int a=three+=one;        int b=three-=one;        int c=three*=one;        int d=three/=one;     int e=three%=one;                System.out.println("three=one+two ==>"+three);        System.out.println("three+=one ==>"+a);        System.out.println("three-=one ==>"+b);        System.out.println("three*=one ==>"+c);        System.out.println("three/=one ==>"+d);        System.out.println("three%=one ==>"+e);        }}

  • 木林森丿
    2020-02-05 20:22:56

    要放在一起算  因为他每一次都运用了前一次的计算结果累计使用的,一次次的算每一次的数值都是初始的赋值  算起来当然不正确。

     int one = 10 ;        int two = 20 ;        int three = 0 ;         three=one+two;        int a=three+=one;        int b=three-=one;        int c=three*=one;        int d=three/=one;        int e=three%=one;         //你的所有System.out.println都错写为System.out.printlin了        System.out.println("three=one+two ==>"+three);    //题目里  ==>  是要打印的内容        System.out.println("three+=one ==>"+a);        System.out.println("three-=one ==>"+b);        System.out.println("three*=one ==>"+c);        System.out.println("three/=one ==>"+d);        System.out.println("three%=one ==>"+e);        }}


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

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

1165172 学习 · 17581 问题

查看课程

相似问题