package chapter04;
public class IncDec {
public static void main(String[] args) {
int a = 10, b = 10, c = 0, d = 0;
System.out.println("a:" + a + " b:" + b + " c:" + c + " d:" + d);
c = a--;
d = ++b;
System.out.println("\nc = a--; d = ++b;");
System.out.println("a:" + a + " b:" + b + " c:" + c + " d:" + d);
c = --a;
d = b++;
System.out.println("\nc = --a; d = b++;");
System.out.println("a:" + a + " b:" + b + " c:" + c + " d:" + d);
d = ++a - b--;
System.out.println("\nd = ++a - b--;");
System.out.println("a:" + a + " b:" + b + " c:" + c + " d:" + d);
a--;
++b;
System.out.println("\na--; ++b;");
System.out.println("a:" + a + " b:" + b + " c:" + c + " d:" + d);
}
}
<出力>
a:10 b:10 c:0 d:0
c = a--; d = ++b;
a:9 b:11 c:10 d:11
c = --a; d = b++;
a:8 b:12 c:8 d:11
d = ++a - b--;
a:9 b:11 c:8 d:-3
a--; ++b;
a:8 b:12 c:8 d:-3