我有这个代码
import java.io.*; import java.util.*;
import javax.xml.parsers.*; import org.xml.sax.InputSource;
class TeamPlayer {
private int pulse;
TeamPlayer() { pulse= -10; }
TeamPlayer(int v0) {pulse= v0 +5;}
public int m(int v) { return 31%3 ;}
public int get_pulse() { return 1* pulse;}
}
class GoalKeeper extends TeamPlayer {
GoalKeeper() { stress -=8; }
public static int stress=3;
public int m(int v) { return (v & 3) + 15; }
}
Run Code Online (Sandbox Code Playgroud)
但我无法理解"&"的含义.它与"&&"不同吗?
Rob*_*gam 11
它是按位"和"运算符.链接:https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
编辑更具体的解释:它用于组合两个数字,其中二进制表示中的位置为1,如果两个数字都为1,则:
0101 & 0000 = 0000
0101 & 1111 = 0101
0101 & 0100 = 0100
...and so on...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7816 次 |
| 最近记录: |