19일차

백엔드를 팝니다·2024년 7월 19일

개발자 수업

목록 보기
14/72

JAVA_연산자

// TODO: 1. 연산자
// 1-1) 증감 연산자 : 변수++, 변수--, ++변수, --변수
// int x = 10;
// int y = 10;
//
// x++; // 1증가식
// y++; // 1증가식
// System.out.println(x);
// System.out.println(y);
//
// ++x;
// ++y;
// System.out.println(y);
// System.out.println(x);
//
// x--;
// y--;
// System.out.println(x);
// System.out.println(y);
//
//
// --x;
// --y;
// System.out.println(x);
// System.out.println(y);
//

// TODO: 1-2) 산술 연산자 : +, -, *, /, % (% 나머지 연산자)
// int x = 1;
// int y = 1;
// System.out.println(x + y);
//
//TODO: 1-3) 논리 연산자 : &&(그리고, and), || (또는, or), !(부정,not)

// boolean play = true;
// System.out.println(play);
//
// // !(부정,not)
//
// play = !play;
// System.out.println(play);
//

	//TODO: 1-4) 비교연산자 : >=, <= , > , < , == , !=

// int num = 1;
// int num2 =1;
// boolean result = (num == num2);
// System.out.println(result);
//
//

// TODO: (주의) char (정수:아스키코드번호, 문자:1문자)
// char char1 = 'A'; // 65
// char char2 = 'B'; // 66
// boolean result = (char1 < char2); // true
// System.out.println(result); // true
//

	//TODO: (*) 3항 연산자 : 사용법 : 자료형 변수 = (조건식)? 참: 거짓

// int score =85;
// String grade = (score > 80)? "A" : "B" ;
// System.out.println(grade);
//

	// 간단연습 : 스코어가 90점 , score가 90보다 작으면 B 라고출력하고 아니면  c라고 출력하세요
	

// int score =90;
// String result = (score < 90)? "B" : "C" ;
// System.out.println(result);
//

// //TODO 2) 축약식: 사용법 : 변수명 = 변수명 +1; => 변수명 +=1;
// int result = 20;
// result = result + 10; // 축약식 변경가능
// result += 10; // 축약식
// System.out.println(result);
//
//
}

}

profile
백엔드 고수가 되고싶은 사람

0개의 댓글