03-operadores-logicos-relacionales.java 556 B

123456789101112131415161718192021222324
  1. class Main {
  2. public static void main(String[] args) {
  3. int a = 5;
  4. int b = 10;
  5. int c = 15;
  6. // Operadores relacionales.
  7. boolean esMayor = (b > c);
  8. System.out.println("b > c = " + esMayor);
  9. boolean esDiferente = (b != c);
  10. System.out.println("b != c = " + esDiferente);
  11. // Operadores lógicos.
  12. boolean isAnd = (a < b) && (b < c);
  13. System.out.println("isAnd = " + isAnd);
  14. boolean isOr = (a == b) || (b == c);
  15. System.out.println("isOr = " + isOr);
  16. System.out.println("isOr negado = " + ! isOr);
  17. }
  18. }