Sample Programs in java

Java example program to check whether the number is odd or even

[java]
/*program to find whether the given number is odd or even*/
/**
@author:candidjava.com
@Description: check the given number to know whether it is odd or even
*/

public class Evenodd {
public static void main(String args[]) {
int a = 70;
if ((a % 2) == 0)
System.out.print("Number is even");
else
System.out.println("number is odd");
}
}
[/java]

Table of Contents

Output:

Number is even