Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
Cars 3 keeps impressing me every day!!! Great question! Yes arrays can be boolean generally, for example in java: boolean[] matrix= new matrix[10];//Creates a boolean array called matrix, of //booleans (true or false) System.out.println(matrix[4]);//Prints the boolean value at position 3 of matrix. The above prints false because the default value of a boolean array element is False. On the other hand If you want, you can avoid boolean array by initializing an integer array of 0 and 1, where 0 is false and 1 is true. So you can type an if statement then like: if(matrix[i]) { //do something} //Which means that if matrix[i]==1 will do something inside if {..} and wont do if //matrix[i]==0.
12th Dec 2018, 8:48 PM
Black Winter
+ 6
Well, yes, arrays can also store booleans if the programming language supports this data type. Can you be more specific with your question? This will lead to better fitting answers for you. Also make sure to mention the programming language in the tags.
12th Dec 2018, 3:23 AM
Matthias
Matthias - avatar