public class Test_36 {
/**
- 测试自增和自减
- @param lei
*/
public static void main(String[] args) {
int c = 1;
int c1 = c + c++;//++在后面先赋值在自增
int c2 = c + ++c;//++在前面先自增在赋值
System.out.println(“c=” + c );//因为++了两次 所有c = 3;
System.out.println(“c1=” + c1 );//c1 = 2;
System.out.println(“c2=” + c2);//c2 = 5;
int s = 3;
int s1 = s + s–;
int s2 = s + --s;
System.out.println(“s=” + s);//因为–了两次 所有s = 1;
System.out.println(“s1=” + s1);//s1 = 6;
System.out.println(“s2=” + s2);//s2 = 3;
}
}