Ask Question
13 March, 12:18

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

+1
Answers (1)
  1. 13 March, 16:05
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers