Answers for "reverse a stack inbuilt function in java"

1

how to reverse the stack in java

public void rev() {
    	ArrayStack s1 = new ArrayStack();
    	int[] data2;
    	data2 = new int[1000];
    	for (int i = 0 ; i<size();i++) {
    		data2[i] = data[i];
    	}
    	
    	for (int i = 0 ; i<size();i++) {
    	 s1.push(data2[i]);
    	}
    	
    	for (int i = 0 ; i<size();i++) {
    		data2[i] = s1.pop();
    		System.out.print(data2[i] + " ");
    	}
    	System.out.println();
    }
Posted by: Guest on April-24-2021

Code answers related to "reverse a stack inbuilt function in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language