processing/java: cannot invoke length() on the array type boolean[]
14,314
Solution 1
For arrays, their lengths are fixed when we create them.
If you want to get the length of any array, use .length
.
Solution 2
.length = to get the length for arrays
.length() = to get the length of Strings
Solution 3
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.
Author by
Muhammad Shahab
Updated on June 12, 2022Comments
-
Muhammad Shahab almost 2 years
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 }