I have written a method that takes a boolean array as input, and returns the conjunction of all of the values in the array using a loop. However, I am trying to do the same thing except using recursion (no for loops allowed) and am having trouble. Any suggestions or hints? Thanks!
Here is what I have written for the iteration part:
public class LogicalOperators {
public static void main(String[] args) {
boolean[] queue = new boolean[] {true, false, true, true, true};
System.out.println(conjunctionIter(queue));
}
public static boolean conjunctionIter(boolean[] queue){
boolean allArrayTrue = true;
for(int i=0; i<queue.length; i++){
if(queue[i] == false){
allArrayTrue = false;
break;
}
}
return allArrayTrue;
}
andall the values in a boolean array recursively, right?