Question: Write a piece of code that finds and prints the longest string in a stack of strings. For example, in the stack [hello, hi, goodbye,
Write a piece of code that finds and prints the longest string in a stack of strings. For example, in the stack [hello, hi, goodbye, howdy], the longest string is "goodbye". When your code is done running, the stack should still contain the same contents as it had at the start. In other words, if you destroy the stack as you examine it, restore its state afterward. If you like, put your code into a method called printLongest that accepts the stack as a parameter.
Step by Step Solution
3.32 Rating (158 Votes )
There are 3 Steps involved in it
public static void printLongest Stack stack Stack backup ... View full answer
Get step-by-step solutions from verified subject matter experts
