Here you can find the source of booleanArrayToInt(boolean[] in)
Parameter | Description |
---|---|
in | a parameter |
public static int booleanArrayToInt(boolean[] in)
//package com.java2s; //License from project: Apache License public class Main { /**//from w ww.java2s . c o m * convert an array of booleans - one ber bit * to an int * @param in * @return */ public static int booleanArrayToInt(boolean[] in) { if (in.length > 32) throw new IllegalArgumentException("no more than 32 bits in an int"); int index = 1; int ret = 0; for (int i = 0; i < in.length; i++) { if (in[i]) ret |= index; index <<= 1; } return ret; } }