mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
init with DEFAULT_CAPACITY
This commit is contained in:
@@ -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