Java Boolean Array And and(boolean a[], boolean b[])

Here you can find the source of and(boolean a[], boolean b[])

Description

Computes vector whose elements are the results of logical AND of the respective elements in the two given vectors.

License

Open Source License

Parameter

Parameter Description
a the first vector
b the second vector

Return

the vector containing logical ANDs of the elements of the two given vectors

Declaration

public static boolean[] and(boolean a[], boolean b[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w  w  w. j av  a  2s  .  c  om
     * Computes vector whose elements are the results of logical AND of the respective
     * elements in the two given vectors.
     * @param a the first vector
     * @param b the second vector
     * @return the vector containing logical ANDs of the elements of the two given vectors
     */
    public static boolean[] and(boolean a[], boolean b[]) {
        boolean[] c = new boolean[a.length];
        for (int i = 0; i < c.length; i++) {
            c[i] = a[i] & b[i];
        }
        return c;
    }
}

Related

  1. and(boolean[] x, boolean[] y)
  2. and(boolean[][] b1, boolean[][] b2)
  3. andRows(boolean[][] data)
  4. ANDWith(boolean[] toChange, boolean[] toAdd)