我想了解一下的這部分代碼(它是一個IP掩碼)什麼是0xffffffff的和<<在java中
int mask = 0xffffffff << (32 - prefix);
System.out.println("Prefix=" + prefix);
System.out.println("Address=" + ip);
int value = mask;
byte[] bytes = new byte[]{
(byte)(value >>> 24), (byte)(value >> 16 & 0xff),
(byte)(value >> 8 & 0xff),
(byte)(value & 0xff) };
try {
InetAddress netAddr = InetAddress.getByAddress(bytes);
System.out.println("Mask=" + netAddr.getHostAddress());
_「我希望有人可以在每行之後放置註釋」_ SO不是代碼翻譯服務。什麼部分不清楚?你搜索了什麼?請參閱http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html –
[位移位運算符。簽名和無符號](http://stackoverflow.com/questions/2244387/bitwise-shift-operators-signed-and-unsigned) – Palpatim