Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- control
- function
- react
- MacOS
- Java
- system
- Class
- DS
- architecture
- DATAPATH
- data structure
- Linux
- while
- CSS
- instruction
- mysql
- php
- XML
- python
- Algorithm
- Pipelining
- javascript
- html
- for
- DB
- computer
- github
- DoM
- web
- MIPS
Archives
- Today
- Total
YYYEJI
[JAVA] 조건부 연산자(Conditional operator) 본문
728x90
조건부 연산자(Conditional operator)란?
If-else 문을 간결하게 해 놓은 코드입니다.
Variable_name = (Boolean_Expression) ? Result1 : Result2 ;
public static void main(String[] args) {
int num = 2;
System.out.print("The number is " + ((num%2==0) ? "positive" : "negative"));
}
조건문에 맞춰서 결과가 true이면 Result1,
결과가 false이면 Result2가 실행됩니다.
◡̈
'Java' 카테고리의 다른 글
[JAVA] for문이란? (0) | 2022.12.24 |
---|---|
[JAVA] Switch 문이란? (0) | 2022.12.24 |
[JAVA] If 문이란? (0) | 2022.12.24 |
[JAVA] Flow of Control (0) | 2022.12.24 |
[JAVA] Scanner 클래스 (0) | 2022.12.24 |