자바스터디 기록
ch02
_01_operator5
package ch_02;
public class _05_operator5 {
public static void main(String[] args) {
//삼항연산자
//결과 = (조건) ? (참의경우 결과값) : (거짓의 경우 결과값)
int x = 5;
int y = 3;
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);
}
}