public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
int num1=one+two;
int num2=three+=one;
int num3 =three-=one;
int num4 =three*=one;
int num5 =three/=one;
int num6 =three%=one;
System.out.println("three = one + two ==>"+num1);
System.out.println("three = one += two ==>"+num2);
System.out.println("three = one -= two ==>"+num3);
System.out.println("three = one *= two ==>"+num4);
System.out.println("three = one /= two ==>"+num5);
System.out.println("three = one %= two ==>"+num6);
}
}
一条语句中不可有两个赋值符号
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
System.out.println(three = one + two );
System.out.println(three = one += two );
System.out.println(three = one -= two );
System.out.println(three = one *= two);
System.out.println(three = one /= two);
System.out.println(three = one %= two );
}
}