본문 바로가기
Algorithm_JAVA

[Java, 코드업 100제] 삼항 연산자

by 코리니덕 2021. 8. 8.

- 삼항 연산자를 사용 했다고 컴파일 속도가 빨라지는 것은 아니다.

import java.util.*;

public class Main1053 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		// 삼항 연산자
		// 입력된 값이 0이면 1, 아니면 0 넣기
		int num = (scan.nextInt() == 0) ? 1:0;
		
		System.out.println(num);
	}
}