劉3535446
2022-08-16 02:05
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.
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);
}
}
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);
Java入门第一季(IDEA工具)升级版
1165538 学习 · 17586 问题
相似问题