//java.lang包下 StringUTF16类下的 equals算法
@HotSpotIntrinsicCandidate
public static boolean equals(byte[] value, byte[] other) {
if (value.length == other.length) {
int len = value.length >> 1;//此段代码是什么意思
for (int i = 0; i < len; i++) {
if (getChar(value, i) != getChar(other, i)) {
return false;
}
}
return true;
}
return false;
}
@HotSpotIntrinsicCandidate
public static boolean equals(byte[] value, byte[] other) {
if (value.length == other.length) {
int len = value.length >> 1;//此段代码是什么意思
for (int i = 0; i < len; i++) {
if (getChar(value, i) != getChar(other, i)) {
return false;
}
}
return true;
}
return false;
}
public static void main(String[] args){
int a=15;//1111
System.out.println(a>>1);//0111
int b=4;//0100
System.out.println(b>>1);//0010 }
}
例如:int a = 5
a变成2进制是:00000000 00000000 00000000 00000101
int b = a>>1
b变成2进制是:00000000 00000000 00000000 00000010
就是把a的二进制向右移一位,多余的删掉,前面补0,所以b的值为2
包括 << << >>>
@3楼,我是用的java se 10
所以除2