why is it not working?
this code is removing the last element in a Stack. i need to remove the last element and then return the element that i removed. how can i make it that it will remove it(i did it well) and then return the element that i removed (struggeling with it)... code: import java.util.*; public class Main { public static void main(String[] args) { Stack<Integer> myStack = new Stack<Integer>(); myStack.add(0); myStack.add(1); myStack.add(2); myStack.add(3); myStack.add(4); System.out.println(myStack); lastAndRemove(myStack); System.out.println(myStack); } public static void lastAndRemove(Stack<Integer> s){ s.remove(s.lastElement()); } }