输出结果为什么不对呢?谢谢老师!!

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

大淼是头长毛狮

2015-12-15 23:20

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

        three /= one;

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

        three %= one;

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

}

}


输出结果为什么是这个呢?

three = one + two ==>30

three =+ one ==>10

three -= one ==>0

three *= one ==>0

three /= one ==>0

three %= one ==>0


写回答 关注

2回答

  • 慕后端6985466
    2016-07-01 21:05:53

    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);
         System.out.println(three-=one);
         System.out.println(three*=one);
         System.out.println(three/=one);
         System.out.println(three%=one);我感觉这样就行你那个是不是有点太麻烦了.


  • 知北遊
    2015-12-15 23:49:26

     three =+ one; 应该是three+=one ,=+相当于赋值

    一万个为什么

    haolihai好厉害啊

    2016-01-06 12:11:58

    共 1 条回复 >

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

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

1165547 学习 · 17586 问题

查看课程

相似问题