//package com.nowjava;
public class Main {/* from 时 代 J a v a - nowjava.com*/
public static void main(String[] argv) throws Exception {
int bitset = 2;
int bitIndex = 2;
System.out.println(clear(bitset, bitIndex));
}
/** maximum index of a bitset (minimum index is 0) */
public static final int MAX_INDEX = 31;
/**
* Sets the bit specified by the index to <code>false</code>.
*
* @param bitset
* a bitset.
* @param bitIndex
* the index of the bit to be cleared.
* @return the bitset with the cleared bit.
* @throws IndexOutOfBoundsException
* if the specified index is negative or greater than
* {@link #MAX_INDEX}
*/
public static int clear(int bitset, int bitIndex)
throws IndexOutOfBoundsException {
checkIndexRange(bitIndex, MAX_INDEX);
return bitset & ~(1 << bitIndex);
}
/**
* Throws an {@link IndexOutOfBoundsException} if the given bit index is
* negative or if it the second argument is <code>true</code> also if the
* index is greater than {@link #MAX_INDEX}.
*
* @param index
* @param checkMax
* @throws IndexOutOfBoundsException
*/
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。