how to reverse elements in stack code example
Example: Reverse Array Usign Stack
public static void reverse(String[] arr){
Stack stack = new Stack();
for(int i = 0; i < arr.length; i++) {
stack.push(arr[i]);
}
for(int i = 0; i < arr.length; i++) {
arr[i] = stack.top();
stack.pop();
}
return;
}