Check if a number is Odd - Android java.lang

Android examples for java.lang:Math

Description

Check if a number is Odd

Demo Code


//package com.java2s;

public class Main {
    /**//from  w  ww  .jav  a2 s . c o m
     * Check if a number is Odd
     * 
     * @param num
     *            int number
     * @return true if the num is odd and false if it's even
     */
    public static boolean isOdd(int num) {
        return !isEven(num);
    }

    /**
     * Check if a number is Even
     * 
     * @param num
     *            int number
     * @return true if the num is even and false if it's odd
     */
    public static boolean isEven(int num) {
        return (num % 2 == 0);
    }
}

Related Tutorials