Home  >  Article  >  Java  >  What is % in java?

What is % in java?

青灯夜游
青灯夜游Original
2019-11-16 15:24:4411701browse

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?

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn