Skip to content

Commit df6e164

Browse files
committed
Fix StackArray.java resize()
1 parent c5e32ea commit df6e164

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

DataStructures/Stacks/StackArray.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ public int peek() {
109109
}
110110

111111
private void resize(int newSize) {
112-
// private int[] transferArray = new int[newSize]; we can't put modifiers here !
113112
int[] transferArray = new int[newSize];
114113

115-
// for(int i = 0; i < stackArray.length(); i++){ the length isn't a method .
116114
for (int i = 0; i < stackArray.length; i++) {
117115
transferArray[i] = stackArray[i];
118-
stackArray = transferArray;
119116
}
117+
// This reference change might be nice in here
118+
stackArray = transferArray;
120119
maxSize = newSize;
121120
}
122121

0 commit comments

Comments
 (0)