gudii9
asked on
countEvens challenge
Hi,
I am working on below challenge
http://codingbat.com/prob/p162010
I wrote my code as below
I am passing all tests
How to improve my design, approach, code? please advise
I am working on below challenge
http://codingbat.com/prob/p162010
I wrote my code as below
public int countEvens(int[] nums) {
int count=0;
for(int n:nums){
if(n%2==0){
count++;
}
}
return count;
}
I am passing all tests
How to improve my design, approach, code? please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could have done a one liner something like:
return IntStream.of(nums).filter(