# 怎么样让three+=one;打印的值以three=0为基础，而不是30.

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;打印的值以three=0为基础从而输出10，而不是40.

85

## 2 回答

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 = three+=one;

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

three = three-=one;

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

three = three*=one;

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

three = three/=one;

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

three = three%=one;

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

}

}

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

int one = 10 ;

int two = 20 ;

int three = 0;

three=one+two;(改一下int a=one+two;)

System.out.println("three = one + two ==>  "+three);(相应的这边对应为a)

three+=one;（此时设int b=a+one=one+two+one=40，three+=one=0

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

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

2022-08-20 回复 有任何疑惑可以回复我~
#2

2022-08-20 回复 有任何疑惑可以回复我~

0/150

Java入门第一季（IDEA工具）升级版
• 参与学习       1151334    人
• 解答问题       17448    个

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