package cn.edu.hpu.example;
public class BoBo {
/**
* @zhj
*/
public static void main(String[] args) {
int a = 0;
int b = a++;// 先赋值再加1
System.out.println("a=" + a + ",b=" + b);
int a1 = 0;
int c = ++a1;// 先加1再赋值
System.out.println("a1=" + a1 + ",c=" + c);
int a2 = 0;
int d = a2--;// 先赋值再减1
System.out.println("a2=" + a2 + ",d=" + d);
int a3 = 0;
int e = --a3;// 先减1再赋值
System.out.println("a3=" + a3 + ",e=" + e);
}
}
结果显示:
a=1,b=0
a1=1,c=1
a2=-1,d=0
a3=-1,e=-1