HashMap.java (HashMap): If 0 is given for initialCapacity paramater, bump it to 1.
2001-03-24 Bryce McKinlay <bryce@albatross.co.nz> * java/util/HashMap.java (HashMap): If 0 is given for initialCapacity paramater, bump it to 1. * java/util/Hashtable.java (Hashtable): Likewise. From-SVN: r40812
This commit is contained in:
parent
aff68f1cd9
commit
f1cd4ab003
3 changed files with 13 additions and 3 deletions
|
@ -157,7 +157,7 @@ public class HashMap extends AbstractMap
|
|||
* @param loadFactor the load factor
|
||||
*
|
||||
* @throws IllegalArgumentException if (initialCapacity < 0) ||
|
||||
* (initialLoadFactor > 1.0) ||
|
||||
* (loadFactor <= 0)
|
||||
*/
|
||||
public HashMap(int initialCapacity, float loadFactor)
|
||||
throws IllegalArgumentException
|
||||
|
@ -167,7 +167,9 @@ public class HashMap extends AbstractMap
|
|||
+ initialCapacity);
|
||||
if (loadFactor <= 0)
|
||||
throw new IllegalArgumentException("Illegal Load Factor: " + loadFactor);
|
||||
|
||||
|
||||
if (initialCapacity == 0)
|
||||
initialCapacity = 1;
|
||||
buckets = new Entry[initialCapacity];
|
||||
this.loadFactor = loadFactor;
|
||||
this.threshold = (int) (initialCapacity * loadFactor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue