Java examples for Language Basics:Bit
set Bit for long value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { long bitmap = 2; int pos = 2; System.out.println(setBit(bitmap, pos)); }/*from ww w. j a va 2 s. c o m*/ public static long setBit(long bitmap, int pos) { return bitmap | (1 << pos); } }