Here you can find the source of booleanToBitflags(boolean[] flags)
public static int booleanToBitflags(boolean[] flags)
//package com.java2s; public class Main { public static int booleanToBitflags(boolean[] flags) { if (flags.length > 31) throw new IllegalArgumentException( "You cannot store more than 31 bits on an int!"); int n = 0; for (int i = 0; i < flags.length; i++) { if (flags[i]) n += (1 << i);//from ww w .ja va2 s. c om } return n; } }