Home >Java >javaTutorial >What does & mean in Java?
When writing Java code, it is inevitable to use various operators. Here I will introduce to you the & in Java. Do you want to know what it means? Then let’s find out with the editor.
& is a bitwise operator - AND, similar to | (or), ! (not).
In the computer, when & is used as a bit operation, 1&1=1, 1&0=0, 0&0=0;
When we usually use this, it is very There are few, and they are generally used for judgment. If both are true, it is true. I believe you must have learned AND or NOT when you studied mathematics before. This is the same as mathematics.
PS: When mentions &, it will definitely mention &&, && is the logical AND , for example, 2 conditions, boolean a=2>3&&1>3, when judging 2>3 is false When , the second condition 1>3 will not be judged, and a=false will be directly judged. When using &, all 2 conditions will be judged, and then a will be assigned false, So generally make logical judgments When using &&, it will be more efficient!
The above is the detailed content of What does & mean in Java?. For more information, please follow other related articles on the PHP Chinese website!