A simple implementation of Java using ternary operators to judge odd and even numbers

Create a class, create a scanner object of the standard input stream in the main method of the class, prompt the user to enter an integer, accept the integer through the scanner method, and then judge the remainder of the number and 2 through the ternary operator. If the remainder is 0, it indicates that it is an even number, otherwise it is an odd number.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>