Answers for "stack in java sentence reverse"

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 "stack in java sentence reverse"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language