Java examples for Language Basics:Bit
get Bit from 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(getBit(bitmap, pos)); }/* www . ja v a 2 s.co m*/ public static boolean getBit(long bitmap, int pos) { return ((1 << pos) & bitmap) != 0; } }