데이터를 처리하여 결과를 산출하는 것
연산자 : 연산에 사용되는 표시나 기호(+, -, *, /, %, =...)
피연산자 : 연산 대상이 되는 데이터(리터럴, 변수)
연산식 : 연산자와 피연산자를 이용하여 기술

ex) 1 + 3 > 1 + 2 -->
4 > 3 -->
true (산술 > 비교)
피연산자가 1개인 연산자
부호 연산자 (+, -) : boolean, char 타입을 제외한 기본 타입에 사용 가능
int num1 = +100;
int num2 = -100;
short num = 100;
short result = -num; //컴파일 에러, 변수를 부호 연산 하면 int 타입으로 산출 됨
int result = -num; //가능
증감 연산자 (++, --)
int x = 1;
int y = 1;
int result1 = ++x + 10; // ++x 먼저 수행 후 x + 10
int result2 = y++ + 10; // y + 10 먼저 수행 후 y++
비트 반전 연산자 (~) : byte, short, int, long 타입만 가능
byte num = 10;
byte result = ~num; // 컴파일 에러 (int 타입으로 산출 됨)
int result = ~num; // -11
00001010 -> 11110101
2의 보수 11110101 -> 00001010+1 -> 00001011 = -11
피연산자가 2개인 연산자
산술 연산자(+, -, *, /, %) : boolean 타입만 불가능
byte num1 = 1;
byte num2 = 2;
byte result = num1 + num2; // 오류 (int 타입으로 계산 됨)
int result = num1 + num2;
int num1 = 10;
int num2 = 4;
double result = num1 / num2; // 2 (int로 계산된 결과가 저장)
char c1 = 'A' + 1; // 'B' (아래와 비교했을 때 리터럴 계산은 가능)
char c2 = 'A';
char c3 = c2 + 1; // 오류 (c2 -> 65 int형으로 계산됨)
int apple = 1;
double pieceUnit = 0.1;
int number = 7;
double result = apple - number * pieceUnit;
// 1 - 0.7 = 0.3이지만 오차로 인해 0.2999999999...로 나옴
5 / 0; // ArithmeticException 예외 발생
5 % 0; // ArithmeticException 예외 발생
5 / 0.0; // Infinity
5 % 0.0; // NaN
Infinity + 2; //Infinity
NaN + 2; // NaN
비교 연산자(==, !=, <, >, <=, >=)
동등 비교 연산자 : 모든 타입 사용 가능
크기 비교 연산자 : boolean 타입 제외 사용 가능
문자열 비교
<, <=, >, >=)연산자 사용 불가equals() 메소드를 사용
String s1 = new String("A");
String s2 = "A";
String s3 = "A";
s1 == s2 -> false // s1과 s2의 데이터 주소값이 다름
s2 == s3 -> true // s2와 s3의 데이터 주소값이 같음
문자열 비교(==) : 데이터 주소값을 비교
equals() : 데이터 값 자체를 비교
논리 연산자(&&, ||, &, |, ^, !)

비트 연산자(&, |, ^, ~, <<, >>, >>>)
float, double은 비트 연산 불가능비트 논리 연산자 (&, |, ^, ~)
boolean타입일 경우 -> 일반 논리 연산자
비트 이동 연산자 (<<, >>, >>>)

int result = 1 << 3; // 왼쪽으로 3칸 시프트 : 8
00000000 00000000 00000000 00000001
00000000 00000000 00000000 00001000
int result = -8 >> 3; // 오른쪽으로 3칸 시프트 : -1
11111111 11111111 11111111 11111000
11111111 11111111 11111111 11111111
int result = -8 >>> 3; // 오른쪽으로 3칸 시프트 (빈자리를 0으로 채움)
11111111 11111111 11111111 11111000
00011111 11111111 11111111 11111111

int score = 95;
char grade = (score > 90) ? 'A' : 'B';
// score가 90보다 크므로 'A'
if문, for문 스킵
int a = 1;
while (a < 10) {
System.out.println(a + "번");
a++;
}
1번
2번
3번
4번
5번
6번
7번
8번
9번
int a = 1;
do{
System.out.println(a + "번");
a++;
} while(a < 10);
1번
2번
3번
4번
5번
6번
7번
8번
9번
int a = 1;
while(true){
System.out.println(a + "번");
a++;
if(a > 10)
break;
}
1번
2번
3번
4번
5번
6번
7번
8번
9번
10번