Here you can find the source of setBit(int value, int bitmask, boolean set)
public static int setBit(int value, int bitmask, boolean set)
//package com.java2s; //License from project: Open Source License public class Main { public static int setBit(int value, int bitmask, boolean set) { if (set) { return bitmask | value; } else {// www . j a v a 2s.co m System.out.println("Reset bit " + value + ": from " + bitmask + " to " + (bitmask & ~value)); return bitmask & ~value; } } }