점점 간단해 진다.
int x=10
1) y = ++x (y==11)
2) y = x++ (y==10, x==11)
식의 결과에 영향을 주지 않고 그 다음 증가한다.
필기시험에 나오는 예제.
package t0922;
import java.util.Scanner;
public class Test01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int x=10;
int y;
y = ++x;
System.out.printf("x=%d, y=%d\n", x, y);
x = 10;
y = x++;
System.out.printf("x=%d, y=%d", x, y);
}
}
다음 x값과 y값은? 이런 식으로 나온다 함
댓글 없음:
댓글 쓰기