Busy today, see the article HashMap working principle of the blog, in the above to see the mod (Take the mold), the thought of taking the remainder symbol%.
Then we looked at some of the information, and now summarize:
Modulo and redundancy methods in Java:
1, Take the mold demo
package com.lbb.test; import java.math.BigInteger; public class RomTest { public Static void main (String[] args) { BigInteger b1; biginteger b2; biginteger b3; b1 = new biginteger ("- "); b2 = new BigInteger ("4"); b3 = b1.mod ( B2); system.out.println ("B3:" + b3); integer i1 = -20;Integer i2 = -3;Integer i3 = i1 % i2; System.out.println ("i3:" + i3); } }
Note: The values calculated by the modulo mod () method are non-negative, especially if the parameters inside the modulo B2 must be positive.
For the remainder of the symbol, there is no special requirement for the divisor and divisor, only the divisor cannot be zero, otherwise it will appear java.lang.ArithmeticException (except 0 exception)
Note: The value is calculated by the percent, positive, negative, 0 can be.
This article is from the "focus on Development Technology" blog, please be sure to keep this source http://bingge2015.blog.51cto.com/4332222/1900016
MoD and% differences in Java