why java revert logical operators while compile

Amit Goel

Actual java code is:

((rrd == null || !rrd) 
    && null != dam
    && null != dam.getac()
    && null != dam.getac().getc() 
    && null != sname 
    && sname.equalsIgnoreCase(dam.getac().getc()))

But when I look into class file it's:

((rrd != null) && (rrd.booleanValue())) 
    || ((((null == dam) 
    || (null == dam.getac()) 
    || (null == dam.getac().getc()) 
    || (null == sname) 
    || (!(sname.equalsIgnoreCase(dam.getac().getc()))))))

All || and && interchanged.

Can anyone explain why?

Stefan Haustein

The expressions are not equivalent but inverted. It looks like the compiler avoids an outer (or implied) not here.

Note that short-circuiting is possible for both operations, || and && -- in the first case when a true sub-expression is encountered and in the second case when a false sub-expression is encountered. So the ability to short-circuit alone does not explain this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Logical Operators in Tweepy Filter

From Dev

Why are some of the logical operators so slow?

From Dev

Combining logical operators in Ruby

From Dev

Why are logical operators in JavaScript left associative?

From Dev

While java provides non short-circuit version of logical operators (like logical |, &), when are these required?

From Dev

Why aren't bitwise operators as smart as logical "and\or" operators

From Dev

More elegant syntax for logical operators for equals() method in Java?

From Dev

Why does VS not define the alternative tokens for logical operators?

From Dev

Logical AND (&&) and OR (||) operators

From Dev

What is the type of the logical operators?

From Dev

Java method that returns logical operators

From Dev

Logical operators with three lists

From Dev

Why are logical assignment (&=) operators disallowed in Typescript?

From Dev

Precedence of the shell logical operators &&, ||

From Dev

Object.equals(Boolean, Boolean) vs Logical Operators (Java)

From Dev

Combining Java 8 lambda predicates with logical operators

From Dev

How are expression with logical operators evaluated in Java?

From Dev

Why Logical operators, when there is Bitwise operators in java

From Dev

Why are some of the logical operators so slow?

From Dev

Determine triangle type WITHOUT logical operators JAVA

From Dev

Why SQL logical operators do not work in c# command?

From Dev

Why are the written versions of logical operators not more widely used?

From Dev

Logical AND (&&) and OR (||) operators

From Dev

why the logical operators change the object

From Dev

Java: Do While with || and && operators

From Dev

Logical operators

From Dev

Logical operators 'AND' / 'OR' in Swift while loop

From Dev

Java logical operators

From Dev

Logical Operators and increment operators

Related Related

  1. 1

    Logical Operators in Tweepy Filter

  2. 2

    Why are some of the logical operators so slow?

  3. 3

    Combining logical operators in Ruby

  4. 4

    Why are logical operators in JavaScript left associative?

  5. 5

    While java provides non short-circuit version of logical operators (like logical |, &), when are these required?

  6. 6

    Why aren't bitwise operators as smart as logical "and\or" operators

  7. 7

    More elegant syntax for logical operators for equals() method in Java?

  8. 8

    Why does VS not define the alternative tokens for logical operators?

  9. 9

    Logical AND (&&) and OR (||) operators

  10. 10

    What is the type of the logical operators?

  11. 11

    Java method that returns logical operators

  12. 12

    Logical operators with three lists

  13. 13

    Why are logical assignment (&=) operators disallowed in Typescript?

  14. 14

    Precedence of the shell logical operators &&, ||

  15. 15

    Object.equals(Boolean, Boolean) vs Logical Operators (Java)

  16. 16

    Combining Java 8 lambda predicates with logical operators

  17. 17

    How are expression with logical operators evaluated in Java?

  18. 18

    Why Logical operators, when there is Bitwise operators in java

  19. 19

    Why are some of the logical operators so slow?

  20. 20

    Determine triangle type WITHOUT logical operators JAVA

  21. 21

    Why SQL logical operators do not work in c# command?

  22. 22

    Why are the written versions of logical operators not more widely used?

  23. 23

    Logical AND (&&) and OR (||) operators

  24. 24

    why the logical operators change the object

  25. 25

    Java: Do While with || and && operators

  26. 26

    Logical operators

  27. 27

    Logical operators 'AND' / 'OR' in Swift while loop

  28. 28

    Java logical operators

  29. 29

    Logical Operators and increment operators

HotTag

Archive