I know everyone prefers using modulus, but that can be slow. If it is an integer, you can do this:
if ( (x & 1) == 0 ) { even... } else { odd... }
This is because the low bit will always be set on an odd number.
Want to learn Java? Check out the Java certification from Intellipaat.