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

求教three=one+two问题,用的手机没办法知道对错

1.public  class  helloworld{
2.public  stail  void  main(string[]args){
3.int  one=10;
4 int  two=20;
5.int  three=0;
6.int  three1=one+two;
7.system.out.println(“three1:”+three);
8.int  three2+=one;
9.int  three3-=one;
10.int  three4*=one;
11.int  three5/=one;
12.int  three6%=one;
14.system.out.println(“three2+=one:”+three);
15.system.out.println(“three3-=one:”+three);
16.system.out.println(“three4*=one:”+three);
17.system.out.println(“three5/=one:”+three);
18.system.out.println(“three6%=one:”+three);
19.
20.{
21.{

这样写运算的结果是对是错?

正在回答

3 回答

错了,估计你要运算的是这个

package wuxin;

   

public class wuxin {

public static void main(String[] args) {

int one=10;

    int two=20;

int three=0;

three=one+two;

System.out.println("three1:"+three);

three += one;

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

three -= one;

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

three *= one;

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

three /= one;

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

three %= one;

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

}

}

输出结果:

three1:30

three2+=one:40

three3-=one:30

three4*=one:300

three5/=one:30

three6%=one:0


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

无心Y

注意一个 three+=one是一个简写,实际是three=three+one 而你用int three1+=one three1没有初始值他不能运算这里也会报错
2016-10-04 回复 有任何疑惑可以回复我~

错了好多

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

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

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

    

}

}


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

举报

0/150
提交
取消

求教three=one+two问题,用的手机没办法知道对错

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号