Surprised that this wasn't already posted. I'm making a for loop, and its worked before but for some reason I can't find the length of a boolean
array.
for(int z = 0; z < keyIsFound.length(); z++){
//do something
}
For arrays, their lengths are fixed when we create them.
If you want to get the length of any array, use .length
.
.length = to get the length for arrays
.length() = to get the length of Strings
For array the length
is a property - not a method. You have to write keyIsFound.length
. Array is a fixed sized data structure when you create an array like -
int[] nums = new int[10];
You actually fixed it length
too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With