Home > Back-end >  About && and | |, really exist different priority?
About && and | |, really exist different priority?

Time:12-29

For Java | in the | and & amp; & Priority problem:
Originally defined as priority is the same, but in the actual operation process, the phenomenon make people feel is a priority,
My explanation is that
& & For the operands bonding degree is higher, but the priority is still the same,
For example:
1. The public class BoolTest {
2. The public static void main (String [] args) {
3. Int a=5, b=5, c=20;
4. The if ((c - & lt; 30) | | (b - & lt; 5) & amp; & (+ & lt; 5))
5. System. Out.println (" a="+ a +"; B="+ b +"; C="+ c);
6.}
7.}
If you think the same priority, the result should be
a=5; B=6; C=19
But the end result is
a=5; B=5; C=10
That is because & amp; & Bonding degree is higher, making the if behind judge c first,
C - & lt; 30 to true
Behind will not continue to execute statements,
The reader can verify the case | | behind with other expressions, can discover, the back will never perform,
  • Related