Java/Operators(연산자)

조건 연산자

Bohemian life 2012. 4. 9. 09:34
public class Opr03 {
  public static void main(String[] args){
    int a=5, b=10;
    int max=a;  //최대값으르 저장할 변수 선언
    //    조건식    참값   거짓값
    //조건식? 수식1 : 수식2
    //조건식에 참이면 수식1 실행 거짓이면 수식2실행
    max = a>b ? a : b;
    System.out.println("max = "+ max);
  }
}