Get Instant Help From 5000+ Experts For
Get Instant Help From 5000+ Experts For

Java Program an example on finding whether a Number is Even or an Odd number

By HWA | Publish On: January 31, 2011 | Posted In:

Java is one of the most popular Programming languages in use today in Application software and Web Applications. It is a general-purpose, concurrent, class based and object oriented language that is specifically designed to have implementation dependencies as possible.

Let us look at an example on finding whether a Number is Even or an Odd number.

public class FindEvenOrOddNumber {

public static void main(String[] args) {

//create an array of 10 numbers
int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10};

for(int i=0; i < numbers.length; i++){
* use modulus operator to check if the number is even or odd.
* If we divide any number by 2 and reminder is 0 then the number is
* even, otherwise it is odd.
if(numbers[i]%2 == 0)
System.out.println(numbers[i] + ” is even number.”);
System.out.println(numbers[i] + ” is odd number.”);


Here in this example an array is being created and defined. Here “for(int i=0; i < numbers.length; i++){ “ is meant to be the initialization and definition. For(int i=0; I < numbers.length; i++ means that the I cannot be zero and must be greater than the divisor in this case because as we move forward in the code we can see that the definition for the array says that if the number is divided by 2 and the remainder is 0 then the number is an even number. But, mathematically 0 is neither an odd nor an even number, so clearly this rule cannot be broken.

The array “create an array of 10 numbers” is being initiated with a loop “for(int i=0; i < numbers.length; i++){ /*” to calculations to be performed which completes the whole array and the outputs of whether the numbers are even or odd are returned.

At we provide the best Java Assignment and Homework help. We also offer Online Tutoring in Java. For more help on Java Programming help you can visit our website at .

This article is in continuation with our previous article on Java Assignment Help

Book Your Assignment

Drop files here or click to upload.
Or click here to upload

Recent Posts

How Students Can Use AI to Enhance Their Grades?

Read More

A Comprehensive Guide on How to Write a Business Plan

Read More

How To Write A Thesis Statement?

Read More

A Comprehensive Guide: Crafting an Effective Dissertation Methodology

Read More

A Quick Guide To Harvard Referencing

Read More

Get assignment help from subject matter experts!

4.7/5 rating | 10,000+ happy students | Great tutors 24/7