[Solved] Logical disjunction of a list of booleans represented by integers [closed]


Probably there could be better solutions, but the following should work for you:

public static void main(String[] args) {
        Integer[] a = new Integer[] { 1, 0, 0, 1, 0, 0 };
        List<Integer> a1 = Arrays.asList(a);
        Integer[] b = new Integer[] { 0, 1, 1, 0, 0, 0 };
        List<Integer> a2 = Arrays.asList(b);
        List<Integer> a3 = new ArrayList();
        for (int i = 0; i < a1.size(); i++) {
            a3.add(a1.get(i) | a2.get(i));
            System.out.print(a3.get(i));
        }
    }

Output:

111100

1

solved Logical disjunction of a list of booleans represented by integers [closed]