public class _05_Operator5 {
public static void main(String[] args) {
//์ผํญ ์ฐ์ฐ์
//๊ฒฐ๊ณผ = (์กฐ๊ฑด) ? (์ฐธ์ ๊ฒฝ์ฐ ๊ฒฐ๊ณผ๊ฐ) : (๊ฑฐ์ง์ ๊ฒฝ์ฐ ๊ฒฐ๊ณผ๊ฐ)
int x = 3;
int y = 5;
int max = (x > y) ? x: y;
System.out.println(max); //5
int min = (x < y) ? x : y;
System.out.println(min); //3
boolean b = (x == y) ? true : false;
System.out.println(b); //false
String s = (x != y) ? "๋ฌ๋ผ์" : "๊ฐ์์";
System.out.println(s); //๋ฌ๋ผ์
}
}
'๐ผ๋ฐฑ์ค๋ > Java ๋ฌธ๋ฒ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
03_02 String2 (0) | 2023.07.04 |
---|---|
03_01 String1 (0) | 2023.07.04 |
02_04 Operator3(๋ ผ๋ฆฌ ์ฐ์ฐ์) (0) | 2023.07.04 |
02_03 Operator3(๋น๊ต ์ฐ์ฐ์) (0) | 2023.07.04 |
02_02 Operator2(๋์ ์ฐ์ฐ์) (0) | 2023.07.04 |