Here you can find the source of toBool(int[] data, int index)
Parameter | Description |
---|---|
data | a parameter |
index | a parameter |
Parameter | Description |
---|---|
IndexOutOfBoundsException | an exception |
public static boolean toBool(int[] data, int index) throws IndexOutOfBoundsException
//package com.java2s; //License from project: Apache License public class Main { /**//from w ww. ja va 2 s . c o m * Extract a boolean value from an array of int data * * @param data * @param index * @return * @throws IndexOutOfBoundsException */ public static boolean toBool(int[] data, int index) throws IndexOutOfBoundsException { int length = data.length; if (index < 0 || index >= length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length); } return data[index] == 0 ? false : true; } }