Please explain why 17 @ = 17

前端 未结 6 2013
[愿得一人]
[愿得一人] 2021-01-28 06:22

I am new to Java, actually programming in general. I understand that the modulus operator (%) returns the remainder of two numbers, however, I do not understand why 17 % 40 = 1

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 06:40

    Java has one important arithmetical operator you may not be familiar with, %, also known as the modulus or remainder operator. The % operator returns the remainder of two numbers. For instance 10 % 3 is 1 because 10 divided by 3 leaves a remainder of 1.

    So in your case 17/40 will leave remainder 17 so result is 17.

    Its same as Like.

    1%10 = 1
    

提交回复
热议问题