Java Boolean From toBool(int[] data, int index)

Here you can find the source of toBool(int[] data, int index)

Description

Extract a boolean value from an array of int data

License

Apache License

Parameter

Parameter Description
data a parameter
index a parameter

Exception

Parameter Description
IndexOutOfBoundsException an exception

Declaration

public static boolean toBool(int[] data, int index) throws IndexOutOfBoundsException 

Method Source Code

//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;
    }
}

Related

  1. toBool(Boolean obj)
  2. toBool(long l)
  3. toBool(String bStr)
  4. toBool(String bv)
  5. toBool(String str)