对否?为什么输出不对提交可以通过?

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

阿斯arth

2015-06-14 19:36

public class HelloWorld{

    public static void main(String[] args) {

   int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        three = one + two ==>30;

        three += one ==> 40;

        three -= one ==> 30;

        three *= one ==> 300;

        three /= one ==> 30;

        three %= one ==> 0;

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

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

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

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

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

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

        为什么输出不对呢
       error: illegal start of expression
three = one + two ==>30;
^
error: illegal start of expression
three += one ==> 40;
^
error: illegal start of expression
three -= one ==> 30;
^
error: illegal start of expression
three *= one ==> 300;
^
error: illegal start of expression
three /= one ==> 30;
^
error: illegal start of expression
three %= one ==> 0;
^
6 errors


写回答 关注

1回答

  • chavin
    2015-06-14 21:01:17
    已采纳

            three = one + two ==>30;

            three += one ==> 40;

            three -= one ==> 30;

            three *= one ==> 300;

            three /= one ==> 30;

            three %= one ==> 0;


    这些代码不对,语法不正确, 举个例子说明一下: three = one + two ==>30;   这一个是输出结果,是自己拼接出来的,你只要通过计算得到正确结果就可以了。

    three = one + two;

    System.out.println("three = one + two ==>" + three);  //three = one + two是自定义输出的

    阿斯arth

    非常感谢!

    2015-06-16 15:21:28

    共 1 条回复 >

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

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

1165551 学习 · 17586 问题

查看课程

相似问题