java/코드 리뷰
3. operator - (1) OpDemo1
Astaroth아스
2020. 3. 20. 09:15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package operator;
public class OpDemo1 {
public static void main(String[] args) {
//증감 연산자 (단항 연산자)
//++, --
//++ : 피연산자의 값을 1 증가시킨다.
//-- : 피연산자의 값을 1 감소시킨다.
int a = 10;
a++;
System.out.println(a);
a++;
System.out.println(a+"\n");
int b = 20;
++b;
System.out.println(b);
++b;
System.out.println(b+"\n");
int c = 30;
c--;
System.out.println(c);
c--;
System.out.println(c);
/* 리터럴로 표시된 값은 상수값이기 때문에 증감연산자로 변경시킬 수 없다. */
}
}
|