CJCoding With Joseph
15per day

Stackable Interface with Undo History

Create a class UndoHistory that implements the provided Stackable interface to track text actions.

Requirements:
- Use a String[] actions array of size 10 and an int top counter (starts at 0) to track the stack.
- push(String item) adds the item at index top and increments top. Ignore if full.
- pop() decrements top and returns the item. Return "empty" if nothing to pop.
- peek() returns the item at top - 1 without removing it. Return "empty" if stack is empty.

Do NOT write a main method.

Expected Output:

Typed B
Typed B
Typed A
empty
Topics:
InterfacesClasses
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.