Home > Back-end >  The difference between Java & and &&
The difference between Java & and &&

Time:10-28

& amp; And & amp; & The difference between

CodePudding user response:

You this understanding has limitations
& Is an arithmetic operation (converted to int do arithmetic)
& & Is a logic operation (only suitable for Boolean operations for Java)
For example,
3 & amp; 5==1
3 & amp; & 5 illegal (only applicable to bool type)

For Boolean false is 0, true is 1
So
True& True can do bit operations, is 1 & amp; 1=1, because it is a Boolean, so the result is converted to Boolean, 1 into a bool is true, the whole calculation process type conversion, so low efficiency
True& & True is normal logic operations, without type conversion, so high efficiency

CodePudding user response:

Do a bool type judgment with & amp; & And | | this two is true
& ^ these are an operator
  • Related