Java prüft, ob die Nummer gerade ist
if (number % 2 == 0) {
// even number
} else {
// odd number
}
Itchy Ibis
if (number % 2 == 0) {
// even number
} else {
// odd number
}
// Java Program to Check if Given Integer is Odd or Even
// Using Bitwise AND
// Importing required classes
import java.util.*;
// Main class
public class GFG {
// Main driver method
public static void main(String[] args)
{
// Declare and initializing integer variable
int n = 91;
// Condition Check
// Bitwise AND of any odd number by 1 gives 1
if ((n & 1) == 1) {
// Print statement
System.out.println("Number is Odd");
}
else {
// Print statement
System.out.println("Number is Even");
}
}
}
if (num % 2 == 0)
{
// even number
}
else
{
// odd number
}