Even odd program in java using array

Hey guys!! Welcome to flower brackets blog. We are going to learn even odd program in java using array.

Even odd program in java using array

Let’s see java program to print odd and even numbers from an array,

Also read – java program to find even or odd

public class EvenOddArray
{
public static void main(String[] args)
{
int numbers[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
System.out.println("List of odd numbers : ");
for(int a = 0; a < numbers.length; a++)
{
if(numbers[a]%2 != 0)
{
System.out.println(numbers[a]);
}
}
System.out.println("List of even numbers : ");
for(int a = 0; a < numbers.length; a++)
{
if(numbers[a]%2 == 0)
{
System.out.println(numbers[a]);
}
}
}
}

Output:

Even odd program in java using array

Related Posts