< prev index next >

src/java.base/share/classes/java/util/Properties.java

Print this page

        

@@ -119,10 +119,14 @@
  * </pre>
  *
  * <p>This class is thread-safe: multiple threads can share a single
  * {@code Properties} object without the need for external synchronization.
  *
+ * @apiNote
+ * The {@code Properties} class does not inherit the concept of a load factor
+ * from its superclass, {@code Hashtable}.
+ * 
  * @author  Arthur van Hoff
  * @author  Michael McCloskey
  * @author  Xueming Shen
  * @since   1.0
  */

@@ -150,18 +154,39 @@
     private transient ConcurrentHashMap<Object, Object> map =
             new ConcurrentHashMap<>(8);
 
     /**
      * Creates an empty property list with no default values.
+     * 
+     * @implNote The initial capacity of a {@code Properties} object created
+     * with this constructor is unspecified.
      */
     public Properties() {
         this(null);
     }
 
     /**
+     * Creates an empty property list with no default values, and with an
+     * initial size accommodating the specified number of elements without the
+     * need to dynamically resize.
+     *
+     * @param  initialCapacity the {@code Properties} will be sized to
+     *         accommodate this many elements 
+     * @throws IllegalArgumentException if the initial capacity is less than
+     *         zero.
+     */
+    public Properties(int initialCapacity) {
+        this(null);
+        map = new ConcurrentHashMap<>(initialCapacity);
+    }
+
+    /**
      * Creates an empty property list with the specified defaults.
      *
+     * @implNote The initial capacity of a {@code Properties} object created
+     * with this constructor is unspecified.
+     * 
      * @param   defaults   the defaults.
      */
     public Properties(Properties defaults) {
         // use package-private constructor to
         // initialize unused fields with dummy values
< prev index next >