Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
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
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter03 : operator2 본문

JAVA/chapter03_input_operator

chapter03 : operator2

GAWON 2023. 5. 25. 15:18
package org.joonzis.ex;

public class Ex03_operator02 {
	public static void main(String[] args) {
		/*
		 * 3. 증감 연산자
		 * 	1) 증가
		 * 		(1) a++ : a를 사용하고 증가
		 * 		(2) ++a : a를 증가하고 사용
		 * 	2) 감소
		 * 		(1) a-- : a를 사용하고 감소
		 * 		(2) --a : a를 감소하고 사용
		 * 
		 * 4. 시프트 연산자
		 *  1) 왼쪽 시프트
		 *  	(1) <<
		 *  	(2) 왼쪽으로 한 자리씩 밀어낸다.
		 *  	(3) 비트 연산
		 *  	(4) 2를 곱하는 효과가 있다.
		 *  2) 오른쪽 시프트
		 *  	(1) >>
		 *  	(2) 오른쪽으로 한 자리씩 밀어낸다.
		 *  	(3) 비트연산
		 *  	(4) 2로 나누는 효과가 있다.
		 */
		
		// 시프트
		int num = 8;
		System.out.println("왼쪽 시프트 : " + (num << 2));
		System.out.println("오른쪽 시프트 : " + (num >> 1));
		
		// 증감
		int num2 = 10;
		System.out.println(num2);	// 변수 원본 출력
		System.out.println(num2++);	// 출력 후 1증가
		System.out.println(++num2); // 1증가 후 출력
		
		
		
		
		
		
	}
}

'JAVA > chapter03_input_operator' 카테고리의 다른 글

chapter03 : Test  (0) 2023.05.25
chapter04 : operator3  (0) 2023.05.25
chapter02 : operator1  (0) 2023.05.25
chapter01 : input  (0) 2023.05.25