Java is an object-oriented programming language and a widely used computer programming language. It has the characteristics of cross-platform, object-oriented, and generic programming. It is widely used in enterprise-level web application development and mobile application development.
#What is % in java?
In Java, % means remainder, and % is the remainder operator.
In the remainder division operation: the dividend divided by the divisor is equal to the quotient plus the remainder. The result of the remainder is the remainder. For example: a=10%3, then the value of a is 1 (remainder is 1).
Operators in Java Basics About %: Any integer modulo 2 is either 0 or 1. How to understand it?
An arbitrary number, divided by 10, the remainder is 0~9.
An arbitrary number, divided by N, the remainder is 0~N-1.
An arbitrary number, divided by 2, the remainder is 0~1.
And M % N means what is the remainder after dividing M by N?
So the result of M % 2 must be 0 or 1.
The above is the detailed content of What is % in java?. For more information, please follow other related articles on the PHP Chinese website!