init with DEFAULT_CAPACITY

This commit is contained in:
shellhub
2019-09-28 22:29:47 +08:00
parent cfc26a865e
commit 20cd57cf81
2 changed files with 24 additions and 0 deletions

View File

@ -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
*