Push and Pop a Generic Stack
easyQuestion 416MyStack<T> holds any type by storing the values in an Object array. The pop() that hands the value back as a T is already written; the push that puts one in is not.
Requirements:
1. Complete push(T value) so it stores the value on top and returns true.
2. Return false and change nothing when the stack is already full.
3. Keep the same top-is-an-index rule the given methods use.
Do NOT write a main method.
Expected output
true true b 1 true 7 null
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Data Structures & AlgorithmsStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.