SHARE
TWEET

Untitled

a guest Jun 26th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Constructs an empty <tt>HashMap</tt> with the specified initial
  3.  * capacity and load factor.
  4.  *
  5.  * @param  initialCapacity the initial capacity
  6.  * @param  loadFactor      the load factor
  7.  * @throws IllegalArgumentException if the initial capacity is negative
  8.  *         or the load factor is nonpositive
  9.  */
  10. public HashMap(int initialCapacity, float loadFactor) {
  11.     if (initialCapacity < 0)
  12.         throw new IllegalArgumentException("Illegal initial capacity: " +
  13.                 initialCapacity);
  14.     if (initialCapacity > MAXIMUM_CAPACITY)
  15.         initialCapacity = MAXIMUM_CAPACITY;
  16.     if (loadFactor <= 0 || Float.isNaN(loadFactor))
  17.         throw new IllegalArgumentException("Illegal load factor: " +
  18.                 loadFactor);
  19.     this.loadFactor = loadFactor;
  20.     this.threshold = tableSizeFor(initialCapacity); // here, threadshold is actually initial capacity
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top