Here you can find the source of setbit(final int num, final int bitnum, final boolean state)
public static int setbit(final int num, final int bitnum, final boolean state)
//package com.java2s; //License from project: Open Source License public class Main { public static int setbit(final int num, final int bitnum, final boolean state) { return (state) ? (num | (1 << bitnum)) : (num & ~(1 << bitnum)); }//from w w w. j a v a 2 s . c o m }