diff --git a/DataStructures/Queues/Queues.java b/DataStructures/Queues/Queues.java index f9bb42e4a..d5b9a8e5c 100644 --- a/DataStructures/Queues/Queues.java +++ b/DataStructures/Queues/Queues.java @@ -9,6 +9,11 @@ package DataStructures.Queues; * */ class Queue { + /** + * Default initial capacity. + */ + private static final int DEFAULT_CAPACITY = 10; + /** * Max size of the queue */ @@ -30,6 +35,13 @@ class Queue { */ private int nItems; + /** + * init with DEFAULT_CAPACITY + */ + public Queue() { + this(DEFAULT_CAPACITY); + } + /** * Constructor * diff --git a/DataStructures/Stacks/StackArray.java b/DataStructures/Stacks/StackArray.java index cc8596293..88da42cd3 100644 --- a/DataStructures/Stacks/StackArray.java +++ b/DataStructures/Stacks/StackArray.java @@ -34,6 +34,11 @@ public class StackArray { System.out.println(myStackArray.peek()); // will print 2 } + /** + * Default initial capacity. + */ + private static final int DEFAULT_CAPACITY = 10; + /** * The max size of the Stack */ @@ -49,6 +54,13 @@ public class StackArray { */ private int top; + /** + * init Stack with DEFAULT_CAPACITY + */ + public StackArray() { + this(DEFAULT_CAPACITY); + } + /** * Constructor *