Copy package sec03 . chap04 ;
public class Ex01 {
public static void main ( String [] args) {
boolean bool1 = true ;
boolean bool2 = false ;
boolean bool3 = ! true ;
boolean bool4 = ! false ;
boolean bool5 = !! bool3;
boolean bool6 = !!! bool3;
boolean bool7 = ! ( 1 > 2 );
boolean bool8 = ! (( 5 / 2 ) == 2.5 );
boolean bool9 = ! (( 3f + 4.0 == 7 ) != ( 'A' < 'B' ));
}
}
Copy package sec03 . chap04 ;
public class Ex02 {
public static void main ( String [] args) {
boolean bool1 = true && true ;
boolean bool2 = true && false ;
boolean bool3 = false && true ;
boolean bool4 = false && false ;
boolean bool5 = true || true ;
boolean bool6 = true || false ;
boolean bool7 = false || true ;
boolean bool8 = false || false ;
int num = 6 ;
// 💡 &&가 ||보다 우선순위 높음
boolean boolA = (num % 3 == 0 ) && (num % 2 == 0 ) || (num > 0 ) && (num > 10 );
boolean boolB = (num % 3 == 0 ) && ((num % 2 == 0 ) || (num > 0 )) && (num > 10 );
}
}
Copy package sec03 . chap04 ;
public class Ex03 {
public static void main ( String [] args) {
int a = 1 , b = 2 , c = 0 , d = 0 , e = 0 , f = 0 ;
boolean bool1 = a < b && c ++ < (d += 3 );
boolean bool2 = a < b || e ++ < (f += 3 );
boolean bool3 = a > b && c ++ < (d += 3 ); // 🔴
boolean bool4 = a > b || e ++ < (f += 3 );
}
}
Copy package sec03 . chap04 ;
public class Ex04 {
int num1 = 3 , num2 = 4 ;
char num1OE = num1 % 2 == 1 ? '홀' : '짝' ;
char num2OE = num2 % 2 == 1 ? '홀' : '짝' ;
}