# Thread: Array Odds and Evens

1. Member
Join Date
Nov 2012
Posts
1
Rep Power
0

## Array Odds and Evens

Create an array of 10 integers. Write a program print all the odd numbers then, on a new line, print out the number of even numbers.
Steps

I'm a newb, and getting stuck on how to properly print out the odds and count the evens. So far I'm getting it to print the odds in a list, but then it's just printing everything else after?

public class ArrayProblem{
public static void main(String[] args){

int [] newArray = {9,45,11,2,4,6,8,10,12,14};

System.out.println("The odd numbers are :");

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

if(newArray[i]/2 != 0){
System.out.println(newArray[i]);
}
else{

}
}
}
}

2. ## Re: Array Odds and Evens

Clearly you need to add some code to the else part. The if handles the odd numbers. So what should the else do?

3. ## Re: Array Odds and Evens

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•