Even Odd Number - Java Language Basics

Java examples for Language Basics:int

Description

Even Odd Number

Demo Code


public class Main {
 
        public static void main(String[] args) {
               /*from  ww w. ja va2 s . co  m*/
                int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10};
               
                for(int i=0; i < numbers.length; i++){
                         if(numbers[i]%2 == 0)
                                System.out.println(numbers[i] + " is even number.");
                         else
                                System.out.println(numbers[i] + " is odd number.");
                }
        }
}
 

Result


Related Tutorials