Here you can find the source of setBit(byte b, int bit)
public static byte setBit(byte b, int bit)
//package com.java2s; //License from project: Open Source License public class Main { public static byte setBit(byte b, int bit) { if (bit < 0 || bit >= 8) return b; return (byte) (b | (1 << bit)); }// w w w . j ava 2s . c om }