比如a=10 b=0 那么 b+=a的值怎么算的40?
package answer;
public class answer {
public static void main(String[] args) {
int a = 10,b = 0,i = 4;
b +=a*i;
System.out.println("b的值是:"+b);
}
}
public class Demo {
public static void main(String[] args){
int a=10,b=0;
for(int i=0;i<3;i++){
b+=a;
}
System.out.println("b="+b);
}
}
public class HelloWorld {
public static void main(String[] args) {
int a=10,b=0;
b+=a;
b+=a;
b+=a;
b+=a;
System.out.println("b的值:"+b);
}
}
说简单点其实就是循环4次。