Max Value in Stack

The requirements are to implement a mechanism in a Java Stack of integers to maintain and return the maximum value and be able to report it.

The first idea that comes up to mind is to use an Iterator. That works but is not as efficient (depending on how the stack is being used).

Following is a screen capture of the Eclipse IDE console: Continue reading “Max Value in Stack”