Ask Question
30 November, 18:39

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. 30 November, 20:06
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers