public class _01_Operator1 {
public static void main(String[] args) {
//์ฐ์ ์ฐ์ฐ์
//์ผ๋ฐ ์ฐ์ฐ
System.out.println(4+2); //6
System.out.println(4-2); //2
System.out.println(4*2); //8
System.out.println(4/2); //2
System.out.println(5/2); //2
System.out.println(2/4); //0
System.out.println(4%2); //0
System.out.println(5%2); //1
//์ฐ์ ์์ ์ฐ์ฐ
System.out.println(2+2*2); //6
System.out.println((2+2)*2); //8
System.out.println(2+(2*2)); //6
//๋ณ์๋ฅผ ์ด์ฉํ ์ฐ์ฐ
int a = 20;
int b = 10;
int c;
c=a+b;
System.out.println(c); //30
c=a-b;
System.out.println(c); //10
c=a*b;
System.out.println(c); //200
c=a/b;
System.out.println(c); //2
c=a%b;
System.out.println(c); //0
//์ฆ๊ฐ ์ฐ์ฐ ++, --
//val++; ๋ฌธ์ฅ ์ํ ํ๊ณ ๋์ ๋ํ๊ธฐ
//++val; ๋ํ๊ณ ๋์ ๋ค๋ฅธ ๋ฌธ์ฅ ์ํ
int val;
val = 10;
System.out.println(val);//10
System.out.println(++val); //11
System.out.println(val); //11
val=10;
System.out.println(val); //10
System.out.println(val++); //10์ด ์ถ๋ ฅ๋๊ณ val์ด 11๋ก ๋ฐ๋๋ค.
System.out.println(val); //11
val=10;
System.out.println(val); //10
System.out.println(--val); //9
System.out.println(val); //9
val=10;
System.out.println(val); //10
System.out.println(val--); //10์ด ์ถ๋ ฅ๋๊ณ val์ด 9๋ก ๋ฐ๋๋ค.
System.out.println(val); //9
//์ํ ๋๊ธฐ๋ฒํธ ํ
int waiting =0;
System.out.println("๋๊ธฐ ์ธ์ : "+ waiting++); //๋๊ธฐ ์ธ์ : 0
System.out.println("๋๊ธฐ ์ธ์ : "+ waiting++); //๋๊ธฐ ์ธ์ : 1
System.out.println("๋๊ธฐ ์ธ์ : "+ waiting++); //๋๊ธฐ ์ธ์ : 2
System.out.println("์ด ๋๊ธฐ ์ธ์ : "+waiting); //์ด ๋๊ธฐ ์ธ์ : 3
}
}