问题 Illegal Load: 0.0

问题:什么情况下Hashtable会出现loadFactor=0.0的情况,堆栈如下

Caused by: java.lang.IllegalArgumentException: Illegal Load: 0.0
    at java.util.Hashtable.<init>(Hashtable.java:157)
    at java.util.Hashtable.<init>(Hashtable.java:175)
    at java.lang.ClassLoader.<init>(ClassLoader.java:152)
    at java.lang.ClassLoader.<init>(ClassLoader.java:206)
    at sun.reflect.DelegatingClassLoader.<init>(ClassDefiner.java:54)
    at sun.reflect.ClassDefiner$1.run(ClassDefiner.java:42)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:39)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
    at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:95)
    at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:313)
    at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1322)
    at java.io.ObjectStreamClass.access$1500(ObjectStreamClass.java:50)
    at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:435)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:411)
    at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:308)
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:545)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)


    public Hashtable(int initialCapacity, float loadFactor) {
    if (initialCapacity < 0)
        throw new IllegalArgumentException("Illegal Capacity: "+
                                               initialCapacity);
        if (loadFactor <= 0 || Float.isNaN(loadFactor))
            throw new IllegalArgumentException("Illegal Load: "+loadFactor);

        if (initialCapacity==0)
            initialCapacity = 1;
    this.loadFactor = loadFactor;
    table = new Entry[initialCapacity];
    threshold = (int)(initialCapacity * loadFactor);
    }

loadFactor负载因子小于或等于0.或者你输入的负载因子不是数字