mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 18:32:56 +08:00
Merge pull request #924 from shellhub/master
init with DEFAULT_CAPACITY
This commit is contained in:
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user