java-- with logical operators (& and &&) or (| and ||)

the difference:

A different meaning: && "AND" means , || a "or" means .

2 use different: a && b: a and b are true it returns true, otherwise returns false; a || b: a or b is true in any one returns true, false otherwise

3 both represent operations, but && operator first expression is not established, the latter expression is not operational, return directly. And & had to judge all expressions.

 

And introduce operator (& and &&):

In common: They have expressed an operator sides are true, the result is true;

difference: 

It represents & sides are calculated during operation, then the judgment;

&& symbols represent something to the left of the operation, and then determine whether it is true, it is true of the right to continue operation and then determine the output is false stopped directly behind the output will not run things.

 

Next introduce or operator (| and ||):

In common: they all expressed either side of both sides of the operator is true, the result is true, both sides are not true, the result is false;

difference:

| Operation are represented on both sides, then the determination result

|| represents the arithmetic sign of things to the left, and then determine whether the true, is true stopped direct output will not be running things behind, it is false to continue operation of the right judgment and then output.

Guess you like

Origin www.cnblogs.com/mike-mei/p/10962779.html