Program to check that a given number is even or odd.
/**
* This program is used to check that given number is even or odd.
* @author W3schools360
*/
public class EvenOrOdd {
/**
* This method is used to check that given no is even or odd.
* @param num
*/
static void evenOdd(int num){
if(num
System.out.println("Given number is even.");
}else{
System.out.println("Given number is odd.");
}
}
public static void main(String args[]){
//method call, no need of object.
evenOdd(123);
}
}
Output
Given number is odd.