I hope this question was not asked before.
In java 8, I have an array of String `myArray` in input and an integer `maxLength`.
I want to count the number of string in my array smaller than maxLength. I WANT to use stream to resolve this issue.

For that I thought to do this :

```
int solution = Arrays.stream(myArray).filter(s -> s.length() <= maxLength).count();

```

However I'm not sure if it is the right way to do this. It will need to go through first array once and then go through the filtered array to count.

But if I don't use a stream, I could easely make an algorithm where I loop once over myArray.

My questions are very easy: Is there a way to resolve this issue with the same time performance than with a loop ? Is it always a "good" solution to use stream ?