How can I code this in a simpler way?
for(int i=0; i<array.length; i++)
{
if(myArray[i] == 0)
{
myBoolean = false;
break;
}
else if(myArray[0] != 0 && myArray[1] != 0 && myArray[2] != 0)
//may continue depending on array length
{
myBoolean = true;
}
}
What I currently have is a "if else statement" that if in my array, just an element is not zero it will change my boolean to true. But what I need is to make sure that all elements in the array is not zero then it will change the boolean to true.