File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -15,16 +15,18 @@ public class StaticArrayQueue implements Queue {
15
15
private int size ;
16
16
17
17
/**
18
- * Constructs a new Queue with a specified capacity.
18
+ * Constructs a new queue with a specified capacity.
19
+ *
20
+ * @param capacity The maximum number of items that the queue can hold.
19
21
*/
20
- public StaticArrayQueue (int size ) {
21
- if (size < 1 ) {
22
- throw new IllegalArgumentException ("Size must be at least 1" );
22
+ public StaticArrayQueue (int capacity ) {
23
+ if (capacity < 1 ) {
24
+ throw new IllegalArgumentException ("Capacity must be at least 1" );
23
25
}
24
- data = new char [size ];
26
+ data = new char [capacity ];
25
27
front = 0 ;
26
28
rear = -1 ;
27
- this . size = 0 ;
29
+ size = 0 ;
28
30
}
29
31
30
32
/**
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ public class StaticArrayStack implements Stack {
13
13
private int top ;
14
14
15
15
/**
16
- * Constructor to initialize the stack with a given size.
16
+ * Constructor to initialize the stack with a given capacity.
17
+ *
18
+ * @param capacity The maximum number of items that the stack can hold.
17
19
*/
18
- public StaticArrayStack (int size ) {
19
- if (size < 1 ) {
20
- throw new IllegalArgumentException ("Size must be at least 1" );
20
+ public StaticArrayStack (int capacity ) {
21
+ if (capacity < 1 ) {
22
+ throw new IllegalArgumentException ("Capacity must be at least 1" );
21
23
}
22
- data = new char [size ];
24
+ data = new char [capacity ];
23
25
top = -1 ;
24
26
}
25
27
You can’t perform that action at this time.
0 commit comments