メソッドの名前は、それが次に近いとあなたは、このコードを自分で実行するprint文を追加しての中間結果を確認する必要があります。2.
の力であるn
数よりも大きいを返す通りコード実行。
あなたは、このメソッドの内部で何が起こっていることになるメソッドnextPowerOf2(6)
を呼び出す場合:
n--; // n becomes 5;
n |= n >> 1; // This is equivalent to n = n | n >> 1.
// Bit shift >> has higher precedence than bitwise OR |.
// This is why it becomes 7. Try it yourself and read about
// these operators.
n |= n >> 2; // n is 7
n |= n >> 4; // n is 7
n |= n >> 8; // n is 7
n |= n >> 16; // n is 7
n++; // n is 8
return n; // return n which is equal to 8 - the next nearest to 6 power of 2.
・ホープ、このことができます。
そこにある[演算子](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html)をすべて知っていますか?これは助けとなる最初のことです;) – AxelH