answersLogoWhite

0


Best Answer

int getNumEvens(final int[] nums) {

int numEvens = 0;

for(int i = 0; i < nums.length; ++i) {

if(nums % 2 == 0) {

++numEvens;

}

}

return numEvens;

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

If(array[] % 2 == 0){ //checks the remainder, if its even then the remainder = 0

// even numbers go in here so insert the print statement and what everelse

}else{

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Return the number of even ints in the given array java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to print all the even numbers of an array in visual basic?

find even number in array


How do you create an odd or even script using PHP?

To determine whether a given number is odd or even: function odd_even($i) { return ($i % 2 == 0 ? 'even' : 'odd'); }


Give an example source code to find the given number is even or odd using method overloading in java?

The following will return true if the number provided is even: boolean isEven(int number) { return number % 2 == 0; } Repeat for other integral data types (such as long), and you have method overloading.The following will return true if the number provided is even: boolean isEven(int number) { return number % 2 == 0; } Repeat for other integral data types (such as long), and you have method overloading.The following will return true if the number provided is even: boolean isEven(int number) { return number % 2 == 0; } Repeat for other integral data types (such as long), and you have method overloading.The following will return true if the number provided is even: boolean isEven(int number) { return number % 2 == 0; } Repeat for other integral data types (such as long), and you have method overloading.


Write a java program to find sum of even and odd numbers in given array?

for(int i = 1; i &lt; 100; i+=2) { System.out.println(i); }


What is represented by an array f 7 rows and 8 rows. I am less than 100 and I am even number?

56


Does a prime number always go an equal number of times?

No. A given number need not even be divisible by a given prime.


What is the only given prime number?

The only even prime number is 2.


How do you find the quartile in an even array of values?

Divide the array in half and get the median of each half


Dicide given number is odd or even?

An even number can be divided by 2 evenly. An odd number will have a remainder of 1 when divided by 2.


How will you know that the root of a given number is even or odd?

Assuming you know that your number is a perfect square, the square root of an even number is even, and the square root of an odd number is odd.


How can you tell whether a given number is a multiple of 2?

If it is even


How do you display all even no in an array?

Loop through each array element; if it is even, print it out. The details, of course, will vary depending on the language; so I give it to you here in pseudocode: for i = 1 to (size of myArray) { if myArray(i) % 2 = 0 print myArray(i) } A syntax similar to "number % 2" is used in many languages to get the remainder of a division by zero. This lets you check whether the number is even (if the remainder is zero) or not.