Skip to content

Commit c70d799

Browse files
authored
Merge pull request TheAlgorithms#819 from yeongmo-j/master
Fix StackArray.java resize()
2 parents c5e32ea + df6e164 commit c70d799

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy