Ask Question

Write java code that displays all the objects in a stack in the order in which they were pushed onto it. after all the objects are displayed, the stack should have the same contents as when you started. files to be submitted: taskademo. java arraystack. java stackinterface. java

+3
Answers (1)
  1. 29 July, 20:55
    0
    Let's assume you have a stack called "s".

    You can very simply print each element out using a for each loop (the iterable (as shown below), or a classic for each loop, if you prefer). This method does not modify the stack in any way.

    s. forEach (System. out::println);
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write java code that displays all the objects in a stack in the order in which they were pushed onto it. after all the objects are ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers